Re: Responding to the insertion or removal of a USB flash drive
- From: "Steve" <sredmyer@xxxxxxxxxx>
- Date: 25 Jul 2006 15:46:44 -0700
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/
.
- Follow-Ups:
- Re: Responding to the insertion or removal of a USB flash drive
- From: Mike D Sutton
- Re: Responding to the insertion or removal of a USB flash drive
- References:
- Responding to the insertion or removal of a USB flash drive
- From: Steve
- Re: Responding to the insertion or removal of a USB flash drive
- From: Mike D Sutton
- Responding to the insertion or removal of a USB flash drive
- Prev by Date: Re: Open With
- Next by Date: Fixing Memory could not be "read"
- Previous by thread: Re: Responding to the insertion or removal of a USB flash drive
- Next by thread: Re: Responding to the insertion or removal of a USB flash drive
- Index(es):
Relevant Pages
|