AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HDD
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Obi-Wahn



Joined: 20 Apr 2006
Posts: 43
Location: Vienna

PostPosted: Thu Dec 06, 2007 7:09 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4515
Location: Boulder, CO

PostPosted: Thu Dec 06, 2007 7:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
dandy



Joined: 09 May 2007
Posts: 45

PostPosted: Sat Dec 08, 2007 9:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4515
Location: Boulder, CO

PostPosted: Sat Dec 08, 2007 10:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
dandy



Joined: 09 May 2007
Posts: 45

PostPosted: Sat Dec 08, 2007 10:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4515
Location: Boulder, CO

PostPosted: Sat Dec 08, 2007 10:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7181

PostPosted: Sat Dec 08, 2007 11:22 pm    Post subject: Reply with quote

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
}


Smile
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4515
Location: Boulder, CO

PostPosted: Sat Dec 08, 2007 11:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7181

PostPosted: Sat Dec 08, 2007 11:30 pm    Post subject: Reply with quote

It works Surprised
I am learning. Smile
Back to top
View user's profile Send private message
dandy



Joined: 09 May 2007
Posts: 45

PostPosted: Sun Dec 09, 2007 1:07 am    Post subject: Reply with quote

great guys, but now who gets the 20$?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4515
Location: Boulder, CO

PostPosted: Sun Dec 09, 2007 1:21 am    Post subject: Reply with quote

dandy wrote:
great guys, but now who gets the 20$?
Skan. He was the first with a working script.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7181

PostPosted: Sun Dec 09, 2007 1:40 am    Post subject: Reply with quote

dandy wrote:
but now who gets the 20$?


Either Laszlo or here
Back to top
View user's profile Send private message
dandy



Joined: 09 May 2007
Posts: 45

PostPosted: Sun Dec 09, 2007 2:43 am    Post subject: Reply with quote

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
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7181

PostPosted: Sun Dec 09, 2007 3:19 am    Post subject: Reply with quote

Thanks Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group