retrieve harddisk`s modell,serial,firmware (Windows only)
Re: retrieve harddisk`s modell,serial,firmware (Windows only
You have to add the following line to above the function call 
Declare SNHDD(CurrentDrive, File$)
			
			
									
									Declare SNHDD(CurrentDrive, File$)
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
						Re: retrieve harddisk`s modell,serial,firmware (Windows only
Exa..
			
			
									
									Code: Select all
If Path$ = ""
  Path$ = "C:\HDD.txt"
EndIf 
Declare SNHDD(CurrentDrive, File$) ;<------ Added
If Val(Fonction$) = 1 
  SNHDD (mvarCurrentDrive, Path$)
Else
  End -2
EndIfʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
						- doctorized
 - Addict

 - Posts: 882
 - Joined: Fri Mar 27, 2009 9:41 am
 - Location: Athens, Greece
 
Re: retrieve harddisk`s modell,serial,firmware (Windows only
Is there a code that supports usb disk drives?
			
			
									
									
						Re: retrieve harddisk`s modell,serial,firmware (Windows only
This should work.doctorized wrote:Is there a code that supports usb disk drives?
Code: Select all
Structure STORAGE_PROPERTY_QUERY
  PropertyId.l;STORAGE_PROPERTY_ID
  QueryType.l;STORAGE_QUERY_TYPE
  AdditionalParameters.l
EndStructure
Structure STORAGE_DEVICE_DESCRIPTOR
  Version.l
  Size.l;                                    As Long
  DeviceType.b;                              As Byte
  DeviceTypeModifier.b;                      As Byte
  RemovableMedia.b;                          As Byte
  CommandQueueing.b;                         As Byte
  VendorIdOffset.l;                          As Long
  ProductIdOffset.l;                         As Long
  ProductRevisionOffset.l;                   As Long
  SerialNumberOffset.l;                      As Long
  BusType.w;                                 As Integer
  RawPropertiesLength.l;                     As Long
  RawDeviceProperties.b;                     As Byte
  Reserved.b[1024]
EndStructure
Structure MEDIA_SERIAL_NUMBER_DATA
  SerialNumberLength.l
  Result.l
  Reserved.l[2]
  Serial.b[1000]
EndStructure : Global USBDevice.MEDIA_SERIAL_NUMBER_DATA
#BusTypeUnknown = 0
#BusTypeScsi=1
#BusTypeAtapi=2
#BusTypeAta=3
#BusType1394=4
#BusTypeSsa=5
#BusTypeFibre=6
#BusTypeUsb=7
#BusTypeRAID=8
#BusTypeMaxReserved = $7F
#IOCTL_STORAGE_QUERY_PROPERTY  = $2D1400
#IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER = $2D0C10 ;2952208
Procedure.l Hex2Dec(h$)
  h$=UCase(h$)
  For r=1 To Len(h$)
    d<<4 : a$=Mid(h$,r,1)
    If Asc(a$)>60
      d+Asc(a$)-55
    Else
      d+Asc(a$)-48
    EndIf
  Next
  ProcedureReturn d
EndProcedure 
OpenConsole()
 PrintN("Enumerate devices")
 For Drives=1 To 26
 
  strDrive.s="\\.\" + Chr(64+Drives) + ":"
  
  hDrive = CreateFile_(strDrive, 0,#FILE_SHARE_READ | #FILE_SHARE_WRITE, 0, #OPEN_EXISTING, 0, 0)
  If hDrive<>-1
  
   PrintN("--------------------------------------------------")
   udtQuery.STORAGE_PROPERTY_QUERY
   udtOut.STORAGE_DEVICE_DESCRIPTOR
   ;clear advanced Info....
   For p=0 To 1023
     IsUSB.b = 0
    udtOut\Reserved[p]=0
   Next p 
   lngResult = DeviceIoControl_(hDrive, #IOCTL_STORAGE_QUERY_PROPERTY, udtQuery,SizeOf(udtQuery), @udtOut, SizeOf(udtOut), @dwOutBytes, 0)
   If lngResult 
    PrintN("Drive " + Chr(64+Drives) + ": is a ")
    Select(udtOut\Bustype) 
     Case     #BusTypeUnknown 
     Case #BusTypeScsi
      PrintN(" SCSI Device")
     Case #BusTypeAtapi
      PrintN(" Atapi Device")
     Case #BusTypeAta
      PrintN(" Ata Device")
     Case #BusType1394
     Case #BusTypeSsa
     Case #BusTypeFibre
     Case #BusTypeUsb
       PrintN(" USB Device")
       IsUSB = 1
     Case #BusTypeRAID
     Case #BusTypeMaxReserved 
     Default
     PrintN("Bustype=" + Str(udtOut\BusType))
    EndSelect
    If udtout\RemovableMedia
     PrintN("Device is Removable Media")
    EndIf
    If udtOut\ProductIdOffset > 0
     PrintN("ProductID=" + PeekS(@udtOut + udtOut\ProductIdOffset))
    EndIf
    If udtOut\ProductRevisionOffset > 0
     PrintN("ProductRevision=" + PeekS(@udtOut +  udtOut\ProductRevisionOffset))
    EndIf
    If udtOut\VendorIdOffset  > 0
     PrintN("VendorID=" + PeekS(@udtOut +  udtOut\VendorIdOffset ))
   EndIf
   
   If  udtOut\SerialNumberOffset  > 0          
     SerialNumber.s=PeekS(@udtOut +  udtOut\SerialNumberOffset )
     Serial.s = Trim(PeekS(@udtOut + udtOut\SerialNumberOffset) )
     PrintN("Serial=" + Serial)     
   EndIf   
    
   
;     If udtOut\SerialNumberOffset  > 0      
;       SerialNumber.s=PeekS(@udtOut +  udtOut\SerialNumberOffset )
;       
;       Now convert into readable format, coz its encrypted in HEX-Ascii
;       sdummy.s=""
;       For t=1 To Len(SerialNumber) Step 2
;         sdummy + Chr(Hex2Dec(Mid(SerialNumber,t,2)))
;       Next t 
;       PrintN("SerialNumber=" + sdummy)    
;     EndIf
     
   Else
    PrintN("No Device-IO info available.. for "+Chr(64+Drives) + ":")
   EndIf
  EndIf
  CloseHandle_(hDrive)
 Next Drives
 
wait.s=Input()
CloseConsole()ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
						- doctorized
 - Addict

 - Posts: 882
 - Joined: Fri Mar 27, 2009 9:41 am
 - Location: Athens, Greece
 
Re: retrieve harddisk`s modell,serial,firmware (Windows only
The code is giving correctly the drive's serial but the name is not correct. I have a WD external disk and ProductID is "External". Other programs return it correctly (WDC WD......). I also noticed that the serial numbers for the internal drives are the ascii codes of the letters in hex. The same does WMI. So, it seems that WMI is responding to #IOCTL_STORAGE_QUERY_PROPERTY. I would like something else.Thunder93 wrote:This should work.![]()
Code: Select all
.......
Re: retrieve harddisk`s modell,serial,firmware (Windows only
The names shows correctly for me.
The Western Digital hard drives not suppose to return WDC.. for ProductID. Just seeing it begin with WD.. is correct. The other programs are combining fields.
Here is my return for C drive.
Enumerate devices
--------------------------------------------------
Drive C: is a
SATA Device
ProductID=WD15EARS-60MVWB0
ProductRevision=51.0
VendorID=WDC
Serial=WD-WCAZA5043287
--------------------------------------------------
... and this is exactly correct returns.
			
			
									
									The Western Digital hard drives not suppose to return WDC.. for ProductID. Just seeing it begin with WD.. is correct. The other programs are combining fields.
Here is my return for C drive.
Enumerate devices
--------------------------------------------------
Drive C: is a
SATA Device
ProductID=WD15EARS-60MVWB0
ProductRevision=51.0
VendorID=WDC
Serial=WD-WCAZA5043287
--------------------------------------------------
... and this is exactly correct returns.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
						- doctorized
 - Addict

 - Posts: 882
 - Joined: Fri Mar 27, 2009 9:41 am
 - Location: Athens, Greece
 
Re: retrieve harddisk`s modell,serial,firmware (Windows only
Take a look here: http://loggialogic.blogspot.gr/2012/03/ ... usb30.htmlThunder93 wrote:The names shows correctly for me.
The Western Digital hard drives not suppose to return WDC.. for ProductID. Just seeing it begin with WD.. is correct. The other programs are combining fields.
Here is my return for C drive.
Enumerate devices
--------------------------------------------------
Drive C: is a
SATA Device
ProductID=WD15EARS-60MVWB0
ProductRevision=51.0
VendorID=WDC
Serial=WD-WCAZA5043287
--------------------------------------------------
... and this is exactly correct returns.
the page is in Japanese but look at the picture. WDC is always there in the beginning and it is treated as VendorID.
It is not vendor and Product ID. It is the model number that comes from the drive via #DFP_RECEIVE_DRIVE_DATA.
					Last edited by doctorized on Sun Sep 07, 2014 10:49 am, edited 1 time in total.
									
			
									
						Re: retrieve harddisk`s modell,serial,firmware (Windows only
Yes but like I said.. The other programs are combining fields to give you that. The 'ProductID' for the hard drive doesn't begin with WDC, it begins with WD.
			
			
									
									ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
						Re: retrieve harddisk`s modell,serial,firmware (Windows only
Btw; already with CrystalDiskInfo. CrystalDiskInfo confirms my other results.
			
			
									
									ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
						- doctorized
 - Addict

 - Posts: 882
 - Joined: Fri Mar 27, 2009 9:41 am
 - Location: Athens, Greece
 
Re: retrieve harddisk`s modell,serial,firmware (Windows only
I have a code that reads the info from internal drives. I do no combination. I just call #DFP_RECEIVE_DRIVE_DATA and in the model number I get "WDC WD.....". Maybe the combination is done by the call. But it is not the point. The point is that you get WD15EARS in the productID (as it is internal drive) and I am taking just "External".Thunder93 wrote:Yes but like I said.. The other programs are combining fields to give you that. The 'ProductID' for the hard drive doesn't begin with WDC, it begins with WD.
Re: retrieve harddisk`s modell,serial,firmware (Windows only
I don't have an external Western Digital HDD near, but I do have other externals HDD. The information is exact still!
			
			
									
									ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
						- doctorized
 - Addict

 - Posts: 882
 - Joined: Fri Mar 27, 2009 9:41 am
 - Location: Athens, Greece
 
Re: retrieve harddisk`s modell,serial,firmware (Windows only
In my case, a docking station is used. I have a WD10EARS plugged in.Thunder93 wrote:I don't have an external Western Digital HDD near, but I do have other externals HDD. The information is exact still!
EDIT: this is what I get:
Code: Select all
Drive L: is a 
 USB Device
ProductID=External        
ProductRevision=2.10
VendorID=Generic 
Serial=WD-WCAV5H710181Code: Select all
strDrive.s="\\.\" + Chr(64+Drives) + ":"Code: Select all
strDrive.s="\\.\PhysicalDrive" + Str(Drives)
I took a look in CrystalDiskInfo's source code, I am not very familiar with C/C++ but I think that WMI is used, without being very sure for this.
Re: retrieve harddisk`s modell,serial,firmware (Windows only
I fetched my external WD My Passport 0820.
PB results:
Drive J: is a
USB Device
ProductID=My Passport 0820
ProductRevision=1007
VendorID=WD
Serial=WX91A9332589
However CrystalDiskInfo shows for serial WD-WX91A9332589
lol.
			
			
									
									PB results:
Drive J: is a
USB Device
ProductID=My Passport 0820
ProductRevision=1007
VendorID=WD
Serial=WX91A9332589
However CrystalDiskInfo shows for serial WD-WX91A9332589
lol.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
						- doctorized
 - Addict

 - Posts: 882
 - Joined: Fri Mar 27, 2009 9:41 am
 - Location: Athens, Greece
 
Re: retrieve harddisk`s modell,serial,firmware (Windows only
Your drive is a true external drive. My drive is not. CreateFile_() with "\\.\PhysicalDrive2" gets a handle but I have no idea how to continue.Thunder93 wrote:I fetched my external WD My Passport 0820.
PB results:
Drive J: is a
USB Device
ProductID=My Passport 0820
ProductRevision=1007
VendorID=WD
Serial=WX91A9332589
However CrystalDiskInfo shows for serial WD-WX91A9332589
lol.
EDIT: above I wrote serial number for "WDC WD...". My mistake. Model number I wanted to say. Sorry.
