 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Obi-Wahn
Joined: 20 Apr 2006 Posts: 43 Location: Vienna
|
Posted: Thu Dec 06, 2007 7:09 pm Post subject: |
|
|
Im not sure about the value of this, but did you mean, you need the VendorID and ProductID (like shown into the "Geräteinstanzkennung" (sorry, i'm using a German version / translated: "device instance id"))?
If it's so, a contact from the Windows-Unattended Board (sorry, german) coded a .exe and a .dll to retrieve this.
I've upped a package including a sample .ahk file (modifications from me: Create Function)
[1] DOWNLOAD PACKAGE
[2] DOWNLOAD SECTION WINDOWS-UNATTENDED-Board |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4515 Location: Boulder, CO
|
Posted: Thu Dec 06, 2007 7:47 pm Post subject: |
|
|
Thanks for the dll, but a quick search in the registry (Vista) revealed that the returned value can be found at a few places:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\WDM
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\disk\Enum
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\partmgr\Enum
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum\IDE
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\disk\Enum
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\partmgr\Enum
Several more cryptic keys also contained this disk ID. If other Windows versions have similar registry entries, there will be no need for a dll or API calls. Except, for security reasons. Has anyone tried to edit these entries in the registry? Windows might reset them, or disallow their changes. |
|
| Back to top |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Sat Dec 08, 2007 9:03 pm Post subject: |
|
|
| Quote: | Laszlo wrote:
You can download it from the trusted SoftPedia: http://www.softpedia.com/progDownload/GetDiskSerial-DLL-Download-23473.html, but it is shareware, you have to register for $15. Why bother? There are free tools, just search the Forum.
I searched and didn't find a Dll solution for this. Most of what I found were command line utilities or only returned the volume serial number, not the serial number the manufacturer gives the drive that cannot be changed by formatting.
Here is a link to the page for the DLL from the original developers:
http://www.devlib.net/getdiskserial.htm
I read through some of the examples provided and came up with this:
Code (Expand - Copy):
RegCode := 000000000000
Drive := 0
hModule := DllCall("LoadLibrary", "Str", "GetDiskSerial.dll")
Serial := DllCall("GetDiskSerial\GetSerialNumber", Int, Drive, Str, RegCode)
Model := DllCall("GetDiskSerial\GetModelNumber", Int, Drive, Str, RegCode)
Revision := DllCall("GetDiskSerial\GetRevisionNo", Int, Drive, Str, RegCode)
Buffer := DllCall("GetDiskSerial\GetBufferSize", Int, Drive, Str, RegCode)
Cylinders := DllCall("GetDiskSerial\GetCylinders", Int, Drive, Str, RegCode)
Heads := DllCall("GetDiskSerial\GetHeads", Int, Drive, Str, RegCode)
Sectors := DllCall("GetDiskSerial\GetSectors", Int, Drive, Str, RegCode)
DllCall("FreeLibrary", "UInt", hModule)
MsgBox Serial: %Serial%`nModel: %Model%`nRevision: %Revision%`nBuffer: %Buffer%`nCylinders: %Cylinders%`nHeads: %Heads%`nSectors: %Sectors% | ´
i bought getdiskserial.dll last night,and the retail version fails to retrieve the real serial number when using the quoted script.
both dlls(demo and retail) works just fine with the examples enclosed with the dll,so it must be bad dllcall code.
im offering 20$ for a working script using dllcall,i just need to retrieve serial number,the other paramethers are not needed.
any people interested can try with the demo dll as its exactly the same as retail but with a nag screen added.
thanks. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4515 Location: Boulder, CO
|
Posted: Sat Dec 08, 2007 10:13 pm Post subject: |
|
|
| I tryed the demo: compiled the VC example with VS'05, under Vista-32. Drive 0 shows some funny characters, otherwise every box is either empty or contains 0. It does not seem to work in my system... |
|
| Back to top |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Sat Dec 08, 2007 10:15 pm Post subject: |
|
|
probably vista related,i tested with winxp sp2,the examples work ok,all data retrieved fine from ide and sata drives.
thanks for taking a look lazlo. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4515 Location: Boulder, CO
|
Posted: Sat Dec 08, 2007 10:26 pm Post subject: |
|
|
| Looking at the results of the AHK version, it looks like the return values of the GetSerialNumber and GetModelNumber are pointers. If true, you have to copy the result to an AHK string, or set the type of the return value of the dllcall to “STR” (last param), but I cannot test it. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 7181
|
Posted: Sat Dec 08, 2007 11:22 pm Post subject: |
|
|
Works for me in XP and SATA Drive
| Code: | hModule := DllCall("LoadLibrary", "Str", "GetDiskSerial.dll")
RegCode := 000000000000
Drive := 0
Serial := LStrCpy( DllCall("GetDiskSerial\GetSerialNumber", Int, Drive, Str, RegCode) )
Model := LStrCpy( DllCall("GetDiskSerial\GetModelNumber", Int, Drive, Str, RegCode) )
MsgBox, % "Serial`t: " Serial "`nModel`t: " Model
LStrCpy( DataPtr="", DataLen=0 ) {
If ! DataLen
DataLen := DllCall( "lstrlen", UInt,DataPtr )
VarSetCapacity( Data, DataLen )
DllCall( "lstrcpy", Str,Data, UInt,DataPtr )
Return Data
} |
 |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4515 Location: Boulder, CO
|
Posted: Sat Dec 08, 2007 11:27 pm Post subject: |
|
|
do these fail? | Code: | Serial := DllCall("GetDiskSerial\GetSerialNumber", "Int",Drive, "Str", RegCode, "STR")
Model := DllCall("GetDiskSerial\GetModelNumber", "Int",Drive, "Str", RegCode, "STR") |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 7181
|
Posted: Sat Dec 08, 2007 11:30 pm Post subject: |
|
|
It works
I am learning.  |
|
| Back to top |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Sun Dec 09, 2007 1:07 am Post subject: |
|
|
| great guys, but now who gets the 20$? |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4515 Location: Boulder, CO
|
Posted: Sun Dec 09, 2007 1:21 am Post subject: |
|
|
| dandy wrote: | | great guys, but now who gets the 20$? | Skan. He was the first with a working script. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 7181
|
Posted: Sun Dec 09, 2007 1:40 am Post subject: |
|
|
| dandy wrote: | | but now who gets the 20$? |
Either Laszlo or here |
|
| Back to top |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Sun Dec 09, 2007 2:43 am Post subject: |
|
|
well, as lazlo said skan and skan said lazlo or autohotkey the 20$ went to autohotkey.
thanks lazlo,skan and chris.
Payment Details
Transaction ID: 5B3033191C974131R
Item Price: $20.00 USD
Total: $20.00 USD
Order Description: AutoHotkey Donation |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 7181
|
Posted: Sun Dec 09, 2007 3:19 am Post subject: |
|
|
Thanks  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|