Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 2:55 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How do I check whether a given USB device is plugged in?
PostPosted: July 15th, 2010, 4:41 pm 
Offline

Joined: December 14th, 2004, 5:08 pm
Posts: 55
Location: Holland
Opus: version 8.0
OS: XP, Vista, Windows7, Windows8
System: Intel Corei7-2600 CPU 3.400GHz
I want to check if a USB device (stick) is availble (plugged in) on a system. Is this possible?
I see it in the Device Manager, so I think it must be possible "somehow" :) (yes lazy here.....)

........

Jim

Opus7.03


For this message ivisionar has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: How do I check whether a given USB device is plugged in?
PostPosted: July 15th, 2010, 6:26 pm 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
Hi Jim,
A while back I got to use the registry system to read the status of attached USB drives, had this in my sticky notes and hope would assist you in your quest

Code:
GotRegKey = "Count" + ReadRegistryKey("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR\\Enum","Count")
GotRegKey += "\n0: " +ReadRegistryKey("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR\\Enum","0")
GotRegKey += "\n1: " + ReadRegistryKey("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR\\Enum","1")


Add that to a button and query the content of GotRegKey

In my case I think I needed to trawl through list of attached drives and see if the serial number is one I am expecting. the first line will capture the number of attached drives, second and third were just a test to see if anything is attached to index 0 or 1 (not sure if the name index here is right...), you can use a loop determined by Count to read any details of the attached USB as desired.


my machine is vista so confirm paths on other Windows OS.

Also did look into wmic (please google that ) that would achieve similar results, but for my desire, didn't need to write/read from files to get the serial number hence abandoned that route, anyone familiar with using CLIPBOARD in Opus? wmic can write its values to a file or clipboard and would be handy within opus to see the content of the clipboard.

eomc40


For this message eomc40 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: How do I check whether a given USB device is plugged in?
PostPosted: July 26th, 2010, 4:10 pm 
Offline

Joined: December 14th, 2004, 5:08 pm
Posts: 55
Location: Holland
Opus: version 8.0
OS: XP, Vista, Windows7, Windows8
System: Intel Corei7-2600 CPU 3.400GHz
Hi eom, sorry for the late replay. Yes it works, thanks. When I thought it more over I can do it also in a .hta file. Google "hta" . In attachment a copy of a hta file. Save text file to harddisk as .hta. Run hta file.. We use it to write dynamically the code in a publication...Only thing the user is need to do is find the Usb Location.

No I didn't have any information about CLIPBOARD, is there something in particular you need to know? Is wmic running on a OS Windows7?

Jim


You do not have the required permissions to view the files attached to this post.


For this message ivisionar has been thanked by : mackavi


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 47 guests


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
You cannot post attachments in this forum

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