AutoHotkey Community

It is currently May 25th, 2012, 12:27 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: July 24th, 2007, 7:20 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
Is there any way to get AHK to find the unique USB serial # associated with a USB flash drive that is plugged into the system? I tried searching but didn't find any info here... I may be using the wrong search terms, though.

It seems that the U3 SDK for newer flash drives has an API for it, but I have no idea how to begin to use an API.... [Link]

_________________
[Join IRC!]
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2007, 7:35 pm 
Offline

Joined: July 2nd, 2006, 7:59 pm
Posts: 87
The following example code will show you the serial of all the USB drives plugged into your system:
Code:
SetFormat, Integer, H
DriveGet, DrvList, List, Removable
Loop, Parse, DrvList
{   DriveGet, DrvSerial, Serial, %A_Loopfield%:
   StringTrimLeft, DrvSerial, DrvSerial,2
   StringUpper, DrvSerial, DrvSerial
   MsgBox,Serial Number of  %A_Loopfield%: is %DrvSerial%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2007, 8:07 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
Amazing! I never knew it would be as simple as the driveget command.

SO... Is there any reason that this function couldn't be used to create a 'poor mans' USB hardware key for sensitive applications?

Code:
Key := "1234xy56" ;Your USB Key Serial Goes Here...

SetFormat, Integer, H
DriveGet, DrvList, List, Removable
Loop, Parse, DrvList
{
   DriveGet, DrvSerial, Serial, %A_Loopfield%:
   StringTrimLeft, DrvSerial, DrvSerial,2
   IfEqual, DrvSerial, %Key%, Gosub Application
}
MsgBox Harware Key Not Found!
ExitApp

Application:
MsgBox Pass
ExitApp

_________________
[Join IRC!]
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2007, 8:21 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
that code would not prevent you from using the same keys on multiple computers at once.

you could loop on Process, Exist instead, so it kills the application if you take out the key.


Also, IfEqual is deprecated
Code:
IfEqual, DrvSerial, %Key%, Gosub Application

;becomes
If (DrvSerial = Key)
  Gosub Application


_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, mc-lemons, Pulover, RoAltmann, Yahoo [Bot] and 21 guests


You can post new topics in this forum
You can 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:
Powered by phpBB® Forum Software © phpBB Group