Re: Responding to the insertion or removal of a USB flash drive

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Mike,

Thanks for the response. I have everything just about working and am
quite happy with it
except that I can not seem to get anything other than the
DBT_DEVICEARRIVAL,
DBT_DEVNODES_CHANGED and the DBT_DEVICEREMOVECOMPLETE messages.

Since I need to know that the user wants to remove the USB device, not
that he already has,
(which is what has happened when the DBT_DEVICEREMOVECOMPLETE message
is recieved)
I need to be able to handle the DBT_DEVICEQUERYREMOVE message. This is
the
message which is supposed to be sent when the user clicks the "Safely
Remove Hardware"
icon in the system tray. However I do not get this message. I have
looked all over and
aside from your code (mentioned in the OP) I can not find any talk of
using these messages
from VB. Do you have any experience with this particular message? BTW
in my searching for
some help on this I did see where very similar things can be done with
the SysInfo OCX.
It however also does not get the DeviceQueryRemove event.

As for the file synchronization on laptops, I was refering to the
Windows feature to setup
Offline files and how windows synchs those files up when a laptop is
reconnected to the
Lan.

Steve

Mike D Sutton wrote:
I would like to create an applcation (using VB 6) that will synchronize
the files from a USB flash drive with those on the systems HD similar
to the synchronize feature Windows does with laptops. So far I have
found that by responding to the WM_DEVICECHANGE message I can determine
when the flash drive has been inserted or is being removed. Thanks to
Mike Sutton and his snippet of code at:
http://groups.google.com/group/microsoft.public.vb.general.discussion/browse_frm/thread/dae87f1eee0bf6e4/8f4b167043f54289?lnk=st&q=&rnum=7&hl=en#8f4b167043f54289.

Since I do not personally own or use a laptop and have only seen this
synchornize function used by others, I am not sure how the app should
work. Can anybody help me with description of the synchornize feature
and possibly things I should be aware of from the coding perspective.

I've never seen any synchronisation feature with the laptop (are you referring the to MS SyncToy 'PowerToy' by any
chance?), however the MS ActiveSync application that works with PDA's does what you describe; copying data between
devices as soon as they're connected.
In this case it's pretty much a transparent operation, there is a small window which shows progress on the desktop, but
only an icon in the system bar of the PDA.
In your case, when the device is connected you'll get the notification and can perform the synchronisation at that
point. If the file exists at both ends then it's up to you to decide which is the more recent, probably based on file
last access time, however this can get messy if either system time is wrong. You should also take into account the case
when the files have been change at both ends, and optionally perform a merge operation (harder than it sounds!) To do
this you would also need to create a backup copy of the file each time it's synced, and check that the backup on the
source system is the same as the current on the destination machine.
To save yourself some of this hassle you may simply want to offload this task onto a third party tool, in this respect I
can highly recommend WinMerge which I use to sync. between 3 different systems and performs all the steps mentioned
above:
http://winmerge.sourceforge.net/
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@xxxxxxxx
WWW: Http://EDais.mvps.org/

.



Relevant Pages

  • iexplore.exe error
    ... >and will be closed by windows" and all of my opened pages ... it doesn't happend anytime. ... If you get a response ... laptop but not my desktop. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: multilevel lists
    ... I don't want to download mail to the laptop because then it's virtually impossible to get the messages to my desktop for storage. ... "Stefan Blom" wrote in message ... Windows 7, I think, primarily because Windows Update works better and is more integrated with the operating system than the Windows Update site was in Windows XP. ... Microsoft Word MVP ...
    (microsoft.public.word.numbering)
  • Re: multiple windows opening
    ... After uninstalling, one must download/run a removal tool to rid the machines of the "leftovers" and then reboot, preferably *before* installing another anti-virus application or security suite (e.g., OneCare). ... run Windows Update manually to make sure the machine's fully patched. ... Windows Firewall and Defender on its own. ... I have had windows live one care from the first setup of this laptop. ...
    (microsoft.public.security)
  • Re: another Windows nightmare
    ... after i hook this hdd up to the other laptop, will i be able to see contents ... of the windows directory. ... is that just because of the boot issue? ... You will need a computer with two cd drives, one of which is a cd/dvd-rw ...
    (microsoft.public.windowsxp.general)
  • Re: computer question
    ... The orchid programs are written for the Windows operating system. ... Judging software only runs under Windows XP ... Obtain 'bootcamp' from Apple and have the laptop run XP natively. ... Optimized virtualization is where you've memorized important phrases like ...
    (rec.gardens.orchids)