Refresh the Windows OS from within Visual Basic

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Mileski

    #1

    Refresh the Windows OS from within Visual Basic

    I've made some program in Visual Basic 2005 that works with changing files
    and folders. After I've finished it, the main problem is to refresh the
    Windows OS. I mean the same thing as when we press F5. Than everything
    refreshes and if we have made changes, they are immediately shown.

    Could someone help me with this matter? A possible solution or maybe an idea
    how to do that?

    Suppose that you see in front of you the Windows XP Desktop and you press F5
    or from the menu with mouse right click you choose Refresh. That refreshes
    the screen. Or in Explorer the same happens. THAT is what I want to do. Not
    reboot the computer. And, refresh is not equal to Rebooting the machine. I
    don't know how you came up with this.

    And about the program, for example: The program moves a file from one place,
    changes its name, and then again moves the file to the same location. If you
    open explorer in that folder, and you execute the above explained program,
    the explorer won't show you the changed name. You must press F5 to refresh
    the Explorer, in order to see that the file has been changed.

    Suppose this case:

    1. Open Explorer, or my computer and in C:\ open a folder named Temp

    2. Create a file there named "text.txt"

    3. Leave the explorer open

    4. Now make a program in VB, that renames this file into for example:
    "example.tx t"

    5. Now compile and run the program. (The filename is changed without a
    problem)

    6. Now go to the Explorer window, and you will still see there the file
    under the name "text.txt" and not "explorer.t xt".

    7. Press now F5, and there it is! You see that the file is changed!

    That is what I want to refresh! When I make a change on the hard disk, I
    want all the active programs working with the disk (like explorer) to notice
    the change, and refresh themselfs.

    I suppose I should do this now through Win API. But I don't know which API
    command actually does the trick.

    Was my explanation better ?

    ps.. And still another thing why I'm moving a file instead of renaming it.
    Try this: make a program in VB that renames a file called "text.txt" into
    "Text.txt" with the difference of the second file has a big letter T. Visual
    basic will report Error, there is already a file named with the same name.
    Operation failed! Than YOU MUST move the file, and put it back with a new
    name.


    Thank you,

    Robert Mileski.



  • CMM

    #2
    Re: Refresh the Windows OS from within Visual Basic

    SHChangeNotify API
    http://msdn.microsoft.com/library/de...angenotify.asp

    --
    -C. Moya

    "Robert Mileski" <r_mileski@hotm ail.com> wrote in message
    news:%23A6iSiWR GHA.3192@TK2MSF TNGP09.phx.gbl. ..[color=blue]
    > I've made some program in Visual Basic 2005 that works with changing files
    > and folders. After I've finished it, the main problem is to refresh the
    > Windows OS. I mean the same thing as when we press F5. Than everything
    > refreshes and if we have made changes, they are immediately shown.
    >
    > Could someone help me with this matter? A possible solution or maybe an
    > idea
    > how to do that?
    >
    > Suppose that you see in front of you the Windows XP Desktop and you press
    > F5
    > or from the menu with mouse right click you choose Refresh. That refreshes
    > the screen. Or in Explorer the same happens. THAT is what I want to do.
    > Not
    > reboot the computer. And, refresh is not equal to Rebooting the machine. I
    > don't know how you came up with this.
    >
    > And about the program, for example: The program moves a file from one
    > place,
    > changes its name, and then again moves the file to the same location. If
    > you
    > open explorer in that folder, and you execute the above explained program,
    > the explorer won't show you the changed name. You must press F5 to refresh
    > the Explorer, in order to see that the file has been changed.
    >
    > Suppose this case:
    >
    > 1. Open Explorer, or my computer and in C:\ open a folder named Temp
    >
    > 2. Create a file there named "text.txt"
    >
    > 3. Leave the explorer open
    >
    > 4. Now make a program in VB, that renames this file into for example:
    > "example.tx t"
    >
    > 5. Now compile and run the program. (The filename is changed without a
    > problem)
    >
    > 6. Now go to the Explorer window, and you will still see there the file
    > under the name "text.txt" and not "explorer.t xt".
    >
    > 7. Press now F5, and there it is! You see that the file is changed!
    >
    > That is what I want to refresh! When I make a change on the hard disk, I
    > want all the active programs working with the disk (like explorer) to
    > notice
    > the change, and refresh themselfs.
    >
    > I suppose I should do this now through Win API. But I don't know which API
    > command actually does the trick.
    >
    > Was my explanation better ?
    >
    > ps.. And still another thing why I'm moving a file instead of renaming it.
    > Try this: make a program in VB that renames a file called "text.txt" into
    > "Text.txt" with the difference of the second file has a big letter T.
    > Visual
    > basic will report Error, there is already a file named with the same name.
    > Operation failed! Than YOU MUST move the file, and put it back with a new
    > name.
    >
    >
    > Thank you,
    >
    > Robert Mileski.
    >
    >
    >[/color]


    Comment

    • Andrew Morton

      #3
      Re: Refresh the Windows OS from within Visual Basic

      Robert Mileski wrote:[color=blue]
      > ps.. And still another thing why I'm moving a file instead of
      > renaming it. Try this: make a program in VB that renames a file
      > called "text.txt" into "Text.txt" with the difference of the second
      > file has a big letter T. Visual basic will report Error, there is
      > already a file named with the same name. Operation failed! Than YOU
      > MUST move the file, and put it back with a new name.[/color]

      Why not change the name to something else and then name it to what you want?
      That way there's no chance that it will end up moving the file between
      disks, which would be very time-consuming compared to just renaming it
      twice.

      There is a function to get a unique filename, but I don't know what it is.

      Andrew


      Comment

      Working...