Leaderboard
Popular Content
Showing content with the highest reputation on 08/09/2019 in all areas
-
AutoIt doesn't have support for array literals. AutoIt array initializers seem to allow that but their syntax is just syntatic sugar. Local $a = [[1, 2], [3,4], MouseGetPos()] is flagged as invalid (Missing subscript dimensions) because MouseGetPos() is one variable (an array) but the initializer expects [$FirstVariable, $SecondVariable] there. It needs to find square brackets around every level where at least one value is provided. Of course 1D arrays (call them lists) don't allow internal square brackets in the init part. Local $a = [[1, 2], [3,4], [MouseGetPos()]] is valid: here's a dump of $a: Array[3][2] [0][0] => Int32 1 [0][1] => Int32 2 [1][0] => Int32 3 [1][1] => Int32 4 [2][0] => Array[2] [0] => Int32 211 [1] => Int32 695 [2][1] => String (0) '' Above, the cell $a[2][1] is initialized (by default) as an empy string, like any uninitialized variable. Incomplete init of an array is possible as long as initializer syntax is used, meaning it finds [<something or not>]. Examples: Local $a[3][3] = [[1, 2], [3]] Content of above: Array[3][3] [0][0] => Int32 1 [0][1] => Int32 2 [0][2] => String (0) '' [1][0] => Int32 3 [1][1] => String (0) '' [1][2] => String (0) '' [2][0] => String (0) '' [2][1] => String (0) '' [2][2] => String (0) '' Another example: Local $a[][3] = [[], [1, Null]] Its content: Array[2][3] [0][0] => String (0) '' [0][1] => String (0) '' [0][2] => String (0) '' [1][0] => Int32 1 [1][1] => Keyword Null [1][2] => String (0) '' Last example: Local $a = [[], [1, Null]] Its content: Array[2][2] [0][0] => String (0) '' [0][1] => String (0) '' [1][0] => Int32 1 [1][1] => Keyword Null In short, the initializer deduces (if necessary) the dimensions of the array being declared by examining the structure and number of square brackets in the explicit init part. Explicit dimensions sizes set limits. If you want a correct init, just do as recommended: Local $a = [[1, 2], [3,4], [MouseGetPos()[0], MouseGetPos()[1]]] and the content of $a is now: Array[3][2] [0][0] => Int32 1 [0][1] => Int32 2 [1][0] => Int32 3 [1][1] => Int32 4 [2][0] => Int32 649 [2][1] => Int32 3811 point
-
Basically, it's trial & error. I examined the element for attached events. Reviewed these and manually triggered them until I achieved the desired effect. Then implemented that in Autoit. P.S. I believe in this case that the "change" event would also have worked.1 point
-
How to Run a Passwordcheck before open the GUI?
svenjatzu reacted to Xenobiologist for a topic
Try this: Everytime you change the password and hit enter, the counter goes +1. After 3 attempts the script exits. #include <MsgBoxConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $THE_PASSWORD = '1234' main() Func main() GUICreate("", 196, 29, @DesktopWidth / 2 - 96, @DesktopHeight / 2 - 62, $WS_POPUP) GUICtrlSetDefBkColor(0xFF0000) GUISetBkColor(0xFF0000) GUICtrlCreateLabel("Passwort", 8, 8, 47, 17) GUICtrlSetColor(-1, 0xFFFFFF) Local $password_I = GUICtrlCreateInput("", 64, 4, 121, 21, $SS_NOTIFY) GUICtrlSetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) Local $counter = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $password_I If GUICtrlRead($password_I) == $THE_PASSWORD Then Run("notepad.exe") ; your stuff Else $counter += 1 EndIf If $counter = 3 Then MsgBox(16, 'ERROR', 'Shame on you!', 5) Exit EndIf EndSwitch WEnd EndFunc ;==>main1 point -
Instead of using a bool $Show, use macro @SW_RESTORE and @SW_MINIMIZE1 point
-
Add the following line to your Sciteuser.properties file -- tabbar.hide.index=11 point
-
_Drive_GetHardwareInfos not reliable
PedroWarlock reacted to KaFu for a topic
After some more research I came to the conclusion that extracting Hardware infos via the Api is a never ending story... better stick to a WMI call for consistent results *sigh*... but at least I managed to "decode" the Serialnumber , at least for me it's now the same returned by WMI as the computer-info tool SIW display (which seems to use wmi too?). ; Generated by AutoIt Scriptomatic February 06, 2011 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output &= "Availability: " & $objItem.Availability & @CRLF $Output &= "BytesPerSector: " & $objItem.BytesPerSector & @CRLF $strCapabilities = $objItem.Capabilities(0) $Output &= "Capabilities: " & $strCapabilities & @CRLF $strCapabilityDescriptions = $objItem.CapabilityDescriptions(0) $Output &= "CapabilityDescriptions: " & $strCapabilityDescriptions & @CRLF $Output &= "Caption: " & $objItem.Caption & @CRLF $Output &= "CompressionMethod: " & $objItem.CompressionMethod & @CRLF $Output &= "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF $Output &= "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF $Output &= "CreationClassName: " & $objItem.CreationClassName & @CRLF $Output &= "DefaultBlockSize: " & $objItem.DefaultBlockSize & @CRLF $Output &= "Description: " & $objItem.Description & @CRLF $Output &= "DeviceID: " & $objItem.DeviceID & @CRLF $Output &= "ErrorCleared: " & $objItem.ErrorCleared & @CRLF $Output &= "ErrorDescription: " & $objItem.ErrorDescription & @CRLF $Output &= "ErrorMethodology: " & $objItem.ErrorMethodology & @CRLF $Output &= "FirmwareRevision: " & $objItem.FirmwareRevision & @CRLF $Output &= "Index: " & $objItem.Index & @CRLF $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output &= "InterfaceType: " & $objItem.InterfaceType & @CRLF $Output &= "LastErrorCode: " & $objItem.LastErrorCode & @CRLF $Output &= "Manufacturer: " & $objItem.Manufacturer & @CRLF $Output &= "MaxBlockSize: " & $objItem.MaxBlockSize & @CRLF $Output &= "MaxMediaSize: " & $objItem.MaxMediaSize & @CRLF $Output &= "MediaLoaded: " & $objItem.MediaLoaded & @CRLF $Output &= "MediaType: " & $objItem.MediaType & @CRLF $Output &= "MinBlockSize: " & $objItem.MinBlockSize & @CRLF $Output &= "Model: " & $objItem.Model & @CRLF $Output &= "Name: " & $objItem.Name & @CRLF $Output &= "NeedsCleaning: " & $objItem.NeedsCleaning & @CRLF $Output &= "NumberOfMediaSupported: " & $objItem.NumberOfMediaSupported & @CRLF $Output &= "Partitions: " & $objItem.Partitions & @CRLF $Output &= "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0) $Output &= "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF $Output &= "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF $Output &= "SCSIBus: " & $objItem.SCSIBus & @CRLF $Output &= "SCSILogicalUnit: " & $objItem.SCSILogicalUnit & @CRLF $Output &= "SCSIPort: " & $objItem.SCSIPort & @CRLF $Output &= "SCSITargetId: " & $objItem.SCSITargetId & @CRLF $Output &= "SectorsPerTrack: " & $objItem.SectorsPerTrack & @CRLF $Output &= "SerialNumber: " & WMISerialNumberConversion($objItem.SerialNumber) & @CRLF ;ClipPut($objItem.SerialNumber) $Output &= "Signature: " & $objItem.Signature & @CRLF $Output &= "Size: " & $objItem.Size & @CRLF $Output &= "Status: " & $objItem.Status & @CRLF $Output &= "StatusInfo: " & $objItem.StatusInfo & @CRLF $Output &= "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF $Output &= "SystemName: " & $objItem.SystemName & @CRLF $Output &= "TotalCylinders: " & $objItem.TotalCylinders & @CRLF $Output &= "TotalHeads: " & $objItem.TotalHeads & @CRLF $Output &= "TotalSectors: " & $objItem.TotalSectors & @CRLF $Output &= "TotalTracks: " & $objItem.TotalTracks & @CRLF $Output &= "TracksPerCylinder: " & $objItem.TracksPerCylinder & @CRLF If MsgBox(1, "WMI Output", $Output) = 2 Then ExitLoop $Output = "" Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDrive") EndIf Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate, 13, 2)) EndFunc ;==>WMIDateStringToDate Func WMISerialNumberConversion($string = "") ; By KaFu If Not $string Then Return Local $string_new, $string_new2 For $i = 1 To StringLen($string) Step 2 ;ConsoleWrite(StringMid($string, $i, 2) & @TAB & Chr("0x" & StringMid($string, $i, 2)) & @CRLF) $string_new &= Chr("0x" & StringMid($string, $i, 2)) Next For $i = 1 To StringLen($string_new) Step 2 $string_new2 &= StringMid($string_new, $i + 1, 1) $string_new2 &= StringMid($string_new, $i, 1) Next $string_new2 = StringStripWS($string_new2, 7) Return $string_new2 EndFunc ;==>WMISerialNumberConversion Edit: And here's a quick&dirty example of how to track down the underlying physical disk serial number from the logical disk drive letter ... Global $s_DriveName_Logical = "c" Global $s_DriveName_Partition Global $s_DriveName_PhysicalDisk $s_DriveName_Logical = StringUpper($s_DriveName_Logical) ; Generated by AutoIt Scriptomatic February 06, 2011 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems ;$Output &= "Antecedent: " & $objItem.Antecedent & @CRLF ;$Output &= "Dependent: " & $objItem.Dependent & @CRLF If StringInStr($objItem.Dependent, 'Win32_LogicalDisk.DeviceID="' & $s_DriveName_Logical & ':"') Then If Not StringInStr($objItem.Antecedent, 'Win32_DiskPartition.DeviceID="') Then MsgBox(0, "Error", "") Else $s_DriveName_Partition = StringMid($objItem.Antecedent, StringInStr($objItem.Antecedent, '"', 0, -2)+1, StringLen($objItem.Antecedent) - StringInStr($objItem.Antecedent, '"', 0, -2) - 1) ;ConsoleWrite($s_DriveName_Partition & @CRLF) ;StringMid( ;StringInStr($objItem.Antecedent, 'Win32_DiskPartition.DeviceID="') EndIf ;ClipPut($objItem.Antecedent) ;\\HEAVENSGATE\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #1" ExitLoop EndIf ;$Output &= "EndingAddress: " & $objItem.EndingAddress & @CRLF ;$Output &= "StartingAddress: " & $objItem.StartingAddress & @CRLF ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop ;$Output="" Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_LogicalDiskToPartition") EndIf ; Generated by AutoIt Scriptomatic February 06, 2011 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDriveToDiskPartition", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output &= "Antecedent: " & $objItem.Antecedent & @CRLF $Output &= "Dependent: " & $objItem.Dependent & @CRLF if StringInStr($objItem.Dependent,$s_DriveName_Partition) Then $s_DriveName_PhysicalDisk = StringMid($objItem.Antecedent, StringInStr($objItem.Antecedent, '"', 0, -2)+1, StringLen($objItem.Antecedent) - StringInStr($objItem.Antecedent, '"', 0, -2) - 1) ExitLoop endif ;If MsgBox(1, "WMI Output", $Output) = 2 Then ExitLoop $Output = "" Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDriveToDiskPartition") EndIf ConsoleWrite($s_DriveName_PhysicalDisk & @crlf) ;exit ; Generated by AutoIt Scriptomatic February 06, 2011 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive WHERE DeviceID='" & $s_DriveName_PhysicalDisk & "'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output &= "Availability: " & $objItem.Availability & @CRLF $Output &= "BytesPerSector: " & $objItem.BytesPerSector & @CRLF $strCapabilities = $objItem.Capabilities(0) $Output &= "Capabilities: " & $strCapabilities & @CRLF $strCapabilityDescriptions = $objItem.CapabilityDescriptions(0) $Output &= "CapabilityDescriptions: " & $strCapabilityDescriptions & @CRLF $Output &= "Caption: " & $objItem.Caption & @CRLF $Output &= "CompressionMethod: " & $objItem.CompressionMethod & @CRLF $Output &= "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF $Output &= "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF $Output &= "CreationClassName: " & $objItem.CreationClassName & @CRLF $Output &= "DefaultBlockSize: " & $objItem.DefaultBlockSize & @CRLF $Output &= "Description: " & $objItem.Description & @CRLF $Output &= "DeviceID: " & $objItem.DeviceID & @CRLF ;ClipPut($objItem.DeviceID) $Output &= "ErrorCleared: " & $objItem.ErrorCleared & @CRLF $Output &= "ErrorDescription: " & $objItem.ErrorDescription & @CRLF $Output &= "ErrorMethodology: " & $objItem.ErrorMethodology & @CRLF $Output &= "FirmwareRevision: " & $objItem.FirmwareRevision & @CRLF $Output &= "Index: " & $objItem.Index & @CRLF $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output &= "InterfaceType: " & $objItem.InterfaceType & @CRLF $Output &= "LastErrorCode: " & $objItem.LastErrorCode & @CRLF $Output &= "Manufacturer: " & $objItem.Manufacturer & @CRLF $Output &= "MaxBlockSize: " & $objItem.MaxBlockSize & @CRLF $Output &= "MaxMediaSize: " & $objItem.MaxMediaSize & @CRLF $Output &= "MediaLoaded: " & $objItem.MediaLoaded & @CRLF $Output &= "MediaType: " & $objItem.MediaType & @CRLF $Output &= "MinBlockSize: " & $objItem.MinBlockSize & @CRLF $Output &= "Model: " & $objItem.Model & @CRLF $Output &= "Name: " & $objItem.Name & @CRLF $Output &= "NeedsCleaning: " & $objItem.NeedsCleaning & @CRLF $Output &= "NumberOfMediaSupported: " & $objItem.NumberOfMediaSupported & @CRLF $Output &= "Partitions: " & $objItem.Partitions & @CRLF $Output &= "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0) $Output &= "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF $Output &= "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF $Output &= "SCSIBus: " & $objItem.SCSIBus & @CRLF $Output &= "SCSILogicalUnit: " & $objItem.SCSILogicalUnit & @CRLF $Output &= "SCSIPort: " & $objItem.SCSIPort & @CRLF $Output &= "SCSITargetId: " & $objItem.SCSITargetId & @CRLF $Output &= "SectorsPerTrack: " & $objItem.SectorsPerTrack & @CRLF $Output &= "SerialNumber: " & WMISerialNumberConversion($objItem.SerialNumber) & @CRLF ;ClipPut($objItem.SerialNumber) $Output &= "Signature: " & $objItem.Signature & @CRLF $Output &= "Size: " & $objItem.Size & @CRLF $Output &= "Status: " & $objItem.Status & @CRLF $Output &= "StatusInfo: " & $objItem.StatusInfo & @CRLF $Output &= "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF $Output &= "SystemName: " & $objItem.SystemName & @CRLF $Output &= "TotalCylinders: " & $objItem.TotalCylinders & @CRLF $Output &= "TotalHeads: " & $objItem.TotalHeads & @CRLF $Output &= "TotalSectors: " & $objItem.TotalSectors & @CRLF $Output &= "TotalTracks: " & $objItem.TotalTracks & @CRLF $Output &= "TracksPerCylinder: " & $objItem.TracksPerCylinder & @CRLF If MsgBox(1, "Logical Drive " & $s_DriveName_Logical & ":\", $Output) = 2 Then ExitLoop $Output = "" Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDrive") EndIf Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate, 13, 2)) EndFunc ;==>WMIDateStringToDate Func WMISerialNumberConversion($string = "") ; By KaFu If Not $string Then Return Local $string_new, $string_new2 For $i = 1 To StringLen($string) Step 2 ;ConsoleWrite(StringMid($string, $i, 2) & @TAB & Chr("0x" & StringMid($string, $i, 2)) & @CRLF) $string_new &= Chr("0x" & StringMid($string, $i, 2)) Next For $i = 1 To StringLen($string_new) Step 2 $string_new2 &= StringMid($string_new, $i + 1, 1) $string_new2 &= StringMid($string_new, $i, 1) Next $string_new2 = StringStripWS($string_new2, 7) Return $string_new2 EndFunc ;==>WMISerialNumberConversion Edit2: Oh, and the SN decoding also works on the DeviceIoControl example . #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <array.au3> $var = DriveGetDrive("all") If Not @error Then For $i = 1 To $var[0] ConsoleWrite($var[$i] & @CRLF) $aRes = _Drive_GetHardwareInfos(StringLeft($var[$i], 1)) ConsoleWrite(@CRLF & $aRes[0] & @CRLF & $aRes[1] & @CRLF & $aRes[2] & @CRLF & @CRLF) ;_ArrayDisplay($aRes, $var[$i]) Next EndIf Func _Drive_GetHardwareInfos($DriveLetter) Local $a_Info_Drive_Hardware_temp[3] Local $Ret, $tTemp $Ret = DllCall('kernel32.dll', 'hwnd', 'CreateFile', _ 'str', '\\.\' & $DriveLetter & ':', _ 'dword', 0, _ 'dword', 0, _ 'ptr', 0, _ 'dword', 3, _ 'dword', 0, _ 'ptr', 0 _ ) If @error Then Return SetError(1, 0, $a_Info_Drive_Hardware_temp) EndIf If $Ret[0] = 0xFFFFFFFF Then Return SetError(2, 0, $a_Info_Drive_Hardware_temp) EndIf Local $hDevice = $Ret[0] Local Const $tagSTORAGE_PROPERTY_QUERY = 'ULONG_PTR PropertyId;ULONG_PTR QueryType;byte AdditionalParameters[4]' Local Const $tagSTORAGE_DESCRIPTOR_HEADER = 'dword Version;dword Size' Local $tSTORAGE_PROPERTY_QUERY = DllStructCreate($tagSTORAGE_PROPERTY_QUERY) DllStructSetData($tSTORAGE_PROPERTY_QUERY, 'PropertyId', 0) DllStructSetData($tSTORAGE_PROPERTY_QUERY, 'QueryType', 0) Local $tSTORAGE_DESCRIPTOR_HEADER = DllStructCreate($tagSTORAGE_DESCRIPTOR_HEADER) $Ret = DllCall('kernel32.dll', 'int', 'DeviceIoControl', _ 'handle', $hDevice, _ 'dword', 0x002D1400, _ 'PTR', DllStructGetPtr($tSTORAGE_PROPERTY_QUERY), _ 'dword', DllStructGetSize($tSTORAGE_PROPERTY_QUERY), _ 'PTR', DllStructGetPtr($tSTORAGE_DESCRIPTOR_HEADER), _ 'dword', DllStructGetSize($tSTORAGE_DESCRIPTOR_HEADER), _ 'dword*', 0, _ 'PTR', 0 _ ) If DllStructGetData($tSTORAGE_DESCRIPTOR_HEADER, "Size") Then Local Const $tagSTORAGE_DEVICE_DESCRIPTOR = 'ulong Version;ulong Size;byte DeviceType;byte DeviceTypeModifier;byte RemovableMedia;byte CommandQueueing;ulong VendorIdOffset;ulong ProductIdOffset;ulong ProductRevisionOffset;ulong SerialNumberOffset;ulong BusType;ulong RawPropertiesLength;byte RawDeviceProperties[' & DllStructGetData($tSTORAGE_DESCRIPTOR_HEADER, "Size") & ']' Local $tSTORAGE_DEVICE_DESCRIPTOR = DllStructCreate($tagSTORAGE_DEVICE_DESCRIPTOR) $Ret = DllCall('kernel32.dll', 'int', 'DeviceIoControl', _ 'handle', $hDevice, _ 'dword', 0x002D1400, _ 'PTR', DllStructGetPtr($tSTORAGE_PROPERTY_QUERY), _ 'dword', DllStructGetSize($tSTORAGE_PROPERTY_QUERY), _ 'PTR', DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR), _ 'dword', DllStructGetSize($tSTORAGE_DEVICE_DESCRIPTOR), _ 'dword*', 0, _ 'PTR', 0 _ ) ConsoleWrite("VendorIdOffset " & DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "VendorIdOffset") & @CRLF) If DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "VendorIdOffset") Then $Ret = DllCall("kernel32.dll", "int", "lstrlen", "ptr", DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR) + DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "VendorIdOffset")) $tTemp = DllStructCreate("char Temp[" & $Ret[0] & "]", DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR) + DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "VendorIdOffset")) $a_Info_Drive_Hardware_temp[0] = DllStructGetData($tTemp, "Temp") EndIf ConsoleWrite("ProductIdOffset " & DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "ProductIdOffset") & @CRLF) If DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "ProductIdOffset") Then $Ret = DllCall("kernel32.dll", "int", "lstrlen", "ptr", DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR) + DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "ProductIdOffset")) $tTemp = DllStructCreate("char Temp[" & $Ret[0] & "]", DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR) + DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "ProductIdOffset")) $a_Info_Drive_Hardware_temp[0] &= DllStructGetData($tTemp, "Temp") EndIf ConsoleWrite("ProductRevisionOffset " & DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "ProductRevisionOffset") & @CRLF) If DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "ProductRevisionOffset") Then $Ret = DllCall("kernel32.dll", "int", "lstrlen", "ptr", DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR) + DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "ProductRevisionOffset")) $tTemp = DllStructCreate("char Temp[" & $Ret[0] & "]", DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR) + DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "ProductRevisionOffset")) $a_Info_Drive_Hardware_temp[1] = DllStructGetData($tTemp, "Temp") EndIf ConsoleWrite("SerialNumberOffset " & DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "SerialNumberOffset") & @CRLF) If "0x" & Hex(DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "SerialNumberOffset")) <> "0xFFFFFFFF" Then $Ret = DllCall("kernel32.dll", "int", "lstrlen", "ptr", DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR) + DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "SerialNumberOffset")) $tTemp = DllStructCreate("char Temp[" & $Ret[0] & "]", DllStructGetPtr($tSTORAGE_DEVICE_DESCRIPTOR) + DllStructGetData($tSTORAGE_DEVICE_DESCRIPTOR, "SerialNumberOffset")) $a_Info_Drive_Hardware_temp[2] = WMISerialNumberConversion(DllStructGetData($tTemp, "Temp")) EndIf EndIf DllCall('kernel32.dll', 'int', 'CloseHandle', 'hwnd', $hDevice) Return $a_Info_Drive_Hardware_temp EndFunc ;==>_Drive_GetHardwareInfos Func WMISerialNumberConversion($string = "") ; By KaFu If Not $string Then Return Local $string_new, $string_new2 For $i = 1 To StringLen($string) Step 2 ;ConsoleWrite(StringMid($string, $i, 2) & @TAB & Chr("0x" & StringMid($string, $i, 2)) & @CRLF) $string_new &= Chr("0x" & StringMid($string, $i, 2)) Next For $i = 1 To StringLen($string_new) Step 2 $string_new2 &= StringMid($string_new, $i + 1, 1) $string_new2 &= StringMid($string_new, $i, 1) Next $string_new2 = StringStripWS($string_new2, 7) Return $string_new2 EndFunc ;==>WMISerialNumberConversion1 point