 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Sean
Joined: 12 Feb 2007 Posts: 2211
|
Posted: Fri Nov 09, 2007 11:40 am Post subject: |
|
|
| Zippo() wrote: | Ran it, got this:
| Quote: | Serial Number: ""
Model Number: "1AS "
Revision Number: "7.24" |
|
That's strange. If it's failed to retrieve the SN, the line of Serial Number: should be completely omitted. Would you try again after replacing the MsgBox, ... in the script with the following?
| Code: | | MsgBox, % (nOff:=NumGet(dd,24,"int")) . " | " . (nOff<>-1 ? """" . DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str") . """" : "") |
| Quote: | | I was looking into IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER after seeing it mentioned in that diskid32.exe link you posted above, but I didn't get a chance today to make a script and test it. |
I think IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER is for USB devices only, but I've never actually tried it. |
|
| Back to top |
|
 |
Zippo() Guest
|
Posted: Fri Nov 09, 2007 12:41 pm Post subject: |
|
|
| Sean wrote: | | That's strange. If it's failed to retrieve the SN, the line of Serial Number: should be completely omitted. Would you try again after replacing the MsgBox, ... in the script with the following? |
Making that change I get:
If that means anything to you
| Sean wrote: | | I think IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER is for USB devices only, but I've never actually tried it. |
Yea, but I figure it can't hurt to try. I'll see if I can get it to work on my USB mini stick or something later on today, then try it on the main drive. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2211
|
Posted: Fri Nov 09, 2007 2:45 pm Post subject: |
|
|
| Zippo() wrote: | Making that change I get:
If that means anything to you  |
It indicates the offset of the serial string is 0. I think it should be interpreted as a failure. I was perplexed at the documentation saying the offset will be set to -1 when failure, and I wondered why not 0 which seemed obviously meaningless either. Now your test deepens it more. Maybe a bug of the documentation. |
|
| Back to top |
|
 |
Zippo() Guest
|
Posted: Fri Nov 09, 2007 8:12 pm Post subject: |
|
|
After searching some more I came to this Delphi page that looks like it works with both IDE and SCSI:
http://www.delphi3000.com/articles/article_4207.asp?SK=
But in the comment section of that page:
| Quote: | | But it doesn't work in the server machine. OS : Windows 2003, SCSI RAID Controller |
Also looks like a PITA to convert to AHK. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2211
|
Posted: Sun Nov 11, 2007 2:29 am Post subject: |
|
|
That's interesting. It worked in my system with PhysicalDrive0, not with Scsi0:, however, I suppose have to use Scsi0: in your case.
| Code: | idxDrv := 0 ; 1, 2, 3. In SCSI case, may have to use 1 instead of 0.
;sDrive := "\\.\PhysicalDrive" . idxDrv
sDrive := "\\.\Scsi" . 0 . ":" ; 1, ..., 15
If Not 1 + hDrive:=DllCall("CreateFile", "Uint", &sDrive, "Uint", 0xC0000000, "Uint", 3, "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 0)
ExitApp
VarSetCapacity(in,28+32,0), VarSetCapacity(out,557)
NumPut(28, in, 0), DllCall("RtlMoveMemory", "Uint", &in+4, "str", "SCSIDISK", "Uint", 8)
NumPut(0x001B0501, in, 16), NumPut(0xEC<<48, in, 32, "int64"), NumPut(idxDrv, in, 40)
If DllCall("DeviceIoControl", "Uint", hDrive, "Uint", 0x0004D008, "Uint", &in, "Uint", VarSetCapacity(in), "Uint", &out, "Uint", VarSetCapacity(out), "UintP", nReturn, "Uint", 0) ; IOCTL_SCSI_MINIPORT
Loop, % StrLen(str:=DllCall("msvcrt\abs", "int", &out+64, "Cdecl Str"))//2
SN .= SubStr(str,2*A_Index,1) . SubStr(str,2*A_Index-1,1)
DllCall("CloseHandle", "Uint", hDrive)
MsgBox, % """" . SN . """"
|
|
|
| Back to top |
|
 |
Guest
|
Posted: Thu Nov 15, 2007 10:35 am Post subject: |
|
|
Hello Sean i am new can u tell me how we can do this
| Code: | OutputvarSN=%SN%
OutputvarMo=%Model%
OutputvarRe=%RN%
if OutputvaSNr = 3JV9HKG9
{
if OutputvarMo = ST380011A
{
if OutputvarRN = 3.06
Msgbox, Data Verified
Else
{
Msgbox, Invalid Data
ExitApp
}
}
Else
{
Msgbox, Invalid Data
ExitApp
}
}
Else
{
Msgbox, Invalid Data
ExitApp
}
ExitApp |
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2211
|
Posted: Thu Nov 15, 2007 2:14 pm Post subject: |
|
|
| Anonymous wrote: | | can u tell me how we can do this |
I guess you're using the second script. Then, replace the line
| Code: | MsgBox, % ((nOff:=NumGet(dd,24,"int"))<>-1 ? "Serial Number:`t""" . DecodeSN(DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str")) . """`n" : "")
. ((nOff:=NumGet(dd,16)) ? "Model Number:`t""" . DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str") . """`n" : "")
. ((nOff:=NumGet(dd,20)) ? "Revision Number:`t""" . DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str") . """`n" : "")
|
with
| Code: | SN:=(nOff:=NumGet(dd,24)) ? DecodeSN(DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str")) : ""
, MN:=(nOff:=NumGet(dd,16)) ? DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str") : ""
, RN:=(nOff:=NumGet(dd,20)) ? DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str") : ""
; MsgBox, % SN . "|" . MN . "|" . RN
|
which stores Serial/Model/Revision Numbers into the variable SN/MN/RN respectively. |
|
| Back to top |
|
 |
Zippo() Guest
|
Posted: Sun Dec 02, 2007 8:28 am Post subject: |
|
|
| Sean wrote: | | That's interesting. It worked in my system with PhysicalDrive0, not with Scsi0:, however, I suppose have to use Scsi0: in your case. |
Been away a while, but still interested in this topic
I just ran the script you posted and got this:
I think I read somewhere that the Vista UAC might be causing problems (filtering some of the information). I ran this as Admin but I'm not sure how that effects the UAC.
I'm going to look for a way to disable UAC completely and then see what happens. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2211
|
Posted: Mon Dec 03, 2007 8:16 am Post subject: |
|
|
| Zippo() wrote: | | I just ran the script you posted and got this: |
That's too bad. Then, I'm out of idea, except one thing: have you tried after set idxDrv to 1? |
|
| Back to top |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Wed Dec 05, 2007 3:30 am Post subject: |
|
|
| Code: | idxDrv := 0 ; 1, 2, 3. In SCSI case, may have to use 1 instead of 0.
;sDrive := "\\.\PhysicalDrive" . idxDrv
sDrive := "\\.\Scsi" . 0 . ":" ; 1, ..., 15
If Not 1 + hDrive:=DllCall("CreateFile", "Uint", &sDrive, "Uint", 0xC0000000, "Uint", 3, "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 0)
ExitApp
VarSetCapacity(in,28+32,0), VarSetCapacity(out,557)
NumPut(28, in, 0), DllCall("RtlMoveMemory", "Uint", &in+4, "str", "SCSIDISK", "Uint", 8)
NumPut(0x001B0501, in, 16), NumPut(0xEC<<48, in, 32, "int64"), NumPut(idxDrv, in, 40)
If DllCall("DeviceIoControl", "Uint", hDrive, "Uint", 0x0004D008, "Uint", &in, "Uint", VarSetCapacity(in), "Uint", &out, "Uint", VarSetCapacity(out), "UintP", nReturn, "Uint", 0) ; IOCTL_SCSI_MINIPORT
Loop, % StrLen(str:=DllCall("msvcrt\abs", "int", &out+64, "Cdecl Str"))//2
SN .= SubStr(str,2*A_Index,1) . SubStr(str,2*A_Index-1,1)
DllCall("CloseHandle", "Uint", hDrive)
MsgBox, % """" . SN . """" |
after running this i get an error:
error: call to non existent function.
specifically: NumPut(28, in, 0), DllCall("RtlMoveMemory", "Uint", &in+4, "str", "SCSIDISK", "Uint", 8)
can anyone tell me what im missing?
thanks |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 7698 Location: Germany (but I only speak English)
|
Posted: Wed Dec 05, 2007 4:33 am Post subject: |
|
|
NumPut requires a recent version of AHK. please download a new copy. _________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me. |
|
| Back to top |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Wed Dec 05, 2007 12:38 pm Post subject: |
|
|
thanks,got it working and tweaked to my needs .
maybe im going to be a little greedy here, but theres any way to replace numput with something else to get this working with ahk 1.0.46.12? |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 7698 Location: Germany (but I only speak English)
|
Posted: Wed Dec 05, 2007 9:15 pm Post subject: |
|
|
search the forum for ExtractInteger and ? InsertInteger ? (I don't remember the second one). They are the functions that were used before NumGet and NumPut were made standard. - you will have to alter the parameters a bit, I think.
What's wrong with using the new version? _________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me. |
|
| Back to top |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Thu Dec 06, 2007 6:32 am Post subject: |
|
|
well,im using close to 200 scripts, and the last time i upgraded i had to rewrite half of them .
probably my fault,because i was using a really old version that time. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 7698 Location: Germany (but I only speak English)
|
Posted: Thu Dec 06, 2007 6:39 pm Post subject: |
|
|
Chris makes a point of not breaking existing scripts whenever possible. You should be largely OK. you can also compile your working old scripts in the old version before upgrading, then you only have to worry if you need to edit the script. _________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me. |
|
| 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
|