Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Nov 20, 2019 9:31 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: USB device detection using windows functionality suite...
PostPosted: Sun Feb 06, 2011 5:16 am 
Offline

Joined: Thu Aug 23, 2007 7:23 pm
Posts: 21
Location: Candy Land
Hello :)

I have been working long hours to detect the insertion of USB devices on windows but so far the results are rather disappointing.
I can detect when a new volume shows up, but the code looks bad and I sometimes get "nilobjectexception" errors, so I'm pretty sure there are far better ways of getting it all done.
I found out that the Windows Functionality Suite (WFS) could help a lot so I downloaded WFS version 2.5 and tested it, but after 6 hours of testing I'm lost.

Basically all I need is to detect the insertion and removal of USB (mass storage) devices (so anything capable of data storage).
I need to see if the USB device is a media device (locally plugged in USB key) or a network device (network storage volume).
The serial number of the device is also important (I'm using the MBS pluggin to detect that right now but would like to find another way).

Here is the code I came up with:

Dim i,n as Integer
n= VolumeCount-1
dim w as WindowsVolumeInformationMBS


For i=0 to n
w=new WindowsVolumeInformationMBS(volume(i).name)

if volume(i).name="A:" then
else

if volume(i).name="C:" then
else

if volume(i).name="D:" then
else

if Volume(i).IsReadable Then
Listbox1.AddRow(Volume(i).name + " is connected"+" with the serial number: "+hex(w.Serial))
end if
end if
end if
end if

Next


I use this in a timer and show the events in a listbox.
So this code is indeed horrible :oops: but its the best I could do, if anybody has some experience with the WFS or with this type of code please help.
Any code correction or code sample shares are welcomed with open arms here :wink:

Thanks for reading.

_________________
I like Pie .


Top
 Profile  
Reply with quote  
 Post subject: Re: USB device detection using windows functionality suite..
PostPosted: Sun Feb 06, 2011 9:07 am 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Look in the "File Processing" module in the WFS. I think it has all the pieces you need (getting info about attached drives, like their type, serial number, size, a list of all attached drives, etc.)

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: USB device detection using windows functionality suite..
PostPosted: Sun Feb 06, 2011 2:55 pm 
Offline

Joined: Thu Aug 23, 2007 7:23 pm
Posts: 21
Location: Candy Land
charonn0 wrote:
Look in the "File Processing" module in the WFS. I think it has all the pieces you need (getting info about attached drives, like their type, serial number, size, a list of all attached drives, etc.)

Thank you so much, works great :-)

_________________
I like Pie .


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group