WinAPIEx.au3 库里怎么缺_Winapi_GetDiskSerialNumber函数呀!
本帖最后由 tttbbb999 于 2011-3-19 17:59 编辑WinAPIEx.au3 库里怎么缺函数呀!
没有下面这个函数:
_Winapi_GetDiskSerialNumber
用的是,AUTOIT_3.3.6.1-2
autoit3udf,里面的winapiex库.第11953行的变量报错,将$error 改为@error就行了,
但是就是没有 _Winapi_GetDiskSerialNumber函数
如果谁有其他版本的winapiex.au3请传我一份,感谢!
已经解决 本帖最后由 yhxhappy 于 2011-3-17 22:18 编辑
; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_GetDiskSerialNumber
; Description....: Retrieves information about the amount of space that is available on a disk volume.
; Syntax.........: _WinAPI_GetDiskFreeSpaceEx ( $sDrive )
; Parameters.....: $sDrive - The drive to retrieve information, in the format D:, E:, etc.
; Return values..: Success - The array containing the following parameters:
; - The total number of available free bytes on a disk. If per-user quotas are being used, this value
; may be less than the total number of free bytes on a disk.
; - The total number of available bytes on a disk. If per-user quotas are being used, this value
; may be less than the total number of bytes on a disk.
; - The total number of free bytes on a disk.
; Failure - 0 and sets the @error flag to non-zero.
; Author.........: Yashied
; Modified.......:
; Remarks........: None
; Related........:
; Link...........: @@MsdnLink@@ GetDiskFreeSpaceEx
; Example........: Yes
; ===============================================================================================================================
Func _WinAPI_GetDiskSerialNumber($sPhysDisk)
$hDisk = _WinAPI_CreateFile("\\.\" & $sPhysDisk, 2, 6, 6, 1)
If $hDisk = -1 Then
Exit(ConsoleWrite("_WinAPI_CreateFile fails, error code: " & _WinAPI_GetLastError() & @CRLF))
EndIf
$tSCIP = DllStructCreate($tagSENDCMDINPARAMS)
$tSCOP = DllStructCreate($tagSENDCMDOUTPARAMS & ";char Buffer")
$tQuery = DllStructCreate($tagSTORAGEPROPERTYQUERY)
$tDescr = DllStructCreate($tagSTORAGEDEVICEDESCRIPTOR)
DllStructSetData($tQuery, "PropertyId", 0)
DllStructSetData($tQuery, "QueryType", 0)
$iResult = __DeviceIoControl($hDisk, $IOCTL_STORAGE_QUERY_PROPERTY, _
$tQuery, DllStructGetSize($tQuery), _
$tDescr, DllStructGetSize($tDescr))
If $iResult = 0 Then
Exit(ConsoleWrite("_DeviceIoControl fails, error code: " & @error & @CRLF))
EndIf
If DllStructGetData($tDescr, "BusType") = 2 Then
DllStructSetData($tSCIP, "Command", 0xA1)
Else
DllStructSetData($tSCIP, "Command", 0xEC)
EndIf
$iResult = __DeviceIoControl($hDisk, $DFP_RECEIVE_DRIVE_DATA, _
$tSCIP, DllStructGetSize($tSCIP), _
$tSCOP, DllStructGetSize($tSCOP))
If $iResult = 0 Then
Exit(ConsoleWrite("_DeviceIoControl fails, error code: " & @error & @CRLF))
EndIf
Dim $sSerialNum
For $i = 21 to 40 Step 2
$sSerialNum &= DllStructGetData($tSCOP, "Buffer", $i + 1)
$sSerialNum &= DllStructGetData($tSCOP, "Buffer", $i)
Next
$sSerialNum = StringReplace($sSerialNum, " ", "")
$tSCIP = 0
$tSCOP = 0
$tQuery = 0
$tDescr = 0
_WinAPI_CloseHandle($hDisk)
Return $sSerialNum
EndFunc 感谢了..只用这一段建个函数文件就行了. 回复 3# tttbbb999
你太有才了,如果单建个文件就行,里面的deviceiocontrol,和那几个结构常量找谁去 这个就是我提取出来的代码,可以单独使用.#Region Header
#Include-once
;#Include <StructureConstants.au3>
#Include <WinAPI.au3>
#RequireAdmin
#EndRegion Header
#Region Global Variables and Constants
; ===============================================================================================================================
; _WinAPI_GetDiskSerialNumber()
; ===============================================================================================================================
Const $IOCTL_STORAGE_BASE = 0x2D
Const $IOCTL_STORAGE_QUERY_PROPERTY = __MakeCtrlCode($IOCTL_STORAGE_BASE, 0x500)
Const $DFP_RECEIVE_DRIVE_DATA = 0x7C088
; ===============================================================================================================================
; *Structure constants
; ===============================================================================================================================
Global Const $tagBITMAP = 'long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits'
Global Const $tagBITMAPINFOHEADER = 'dword biSize;long biWidth;long biHeight;ushort biPlanes;ushort biBitCount;dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant'
;Global Const $tagBITMAPINFO = $tagBITMAPINFOHEADER & ';dword bmiColors'
Global Const $tagDIBSECTION = $tagBITMAP & ';' & $tagBITMAPINFOHEADER & ';dword dsBitfields;ptr dshSection;dword dsOffset'
Global Const $tagDISK_GEOMETRY = 'int64 Cylinders;dword MediaType;dword TracksPerCylinder;dword SectorsPerTrack;dword BytesPerSector'
Global Const $tagDISK_GEOMETRY_EX = $tagDISK_GEOMETRY & ';int64 DiskSize;dword Data'
Global Const $tagEXTLOGPEN = 'dword PenStyle;dword Width;uint BrushStyle;dword Color;ulong_ptr Hatch;dword NumEntries' ; & ';dword StyleEntry'
Global Const $tagLOGBRUSH = 'uint Style;dword Color;ulong_ptr Hatch'
Global Const $tagLOGPEN = 'uint Style;dword Width;dword Color'
Global Const $tagLUID = 'dword LowPart;long HighPart'
Global Const $tagNOTIFYICONDATA = 'dword Size;hwnd hWnd;uint ID;uint Flags;uint CallbackMessage;ptr hIcon;wchar Tip;dword State;dword StateMask;wchar Info;uint Version;wchar InfoTitle;dword InfoFlags'
Global Const $tagNOTIFYICONDATA_XP = $tagNOTIFYICONDATA & ';uint GUID'
Global Const $tagNOTIFYICONDATA_VISTA = $tagNOTIFYICONDATA_XP & ';ptr hBalloonIcon'
Global Const $tagSHFILEINFO = 'ptr hIcon;int iIcon;dword Attributes;wchar DisplayName;wchar TypeName'
Global Const $tagOSVERSIONINFO = 'dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion'
Global Const $tagOSVERSIONINFOEX = $tagOSVERSIONINFO & ';short ServicePackMajor;short ServicePackMinor;short SuiteMask;byte ProductType;byte Reserved'
Global Const $tagPAINTSTRUCT = 'hwnd hDC;int fErase;dword rPaint;int fRestore;int fIncUpdate;byte rgbReserved'
Global Const $tagPROCESS_MEMORY_COUNTERS = 'dword Size;dword PageFaultCount;long PeakWorkingSetSize;long WorkingSetSize;long QuotaPeakPagedPoolUsage;long QuotaPagedPoolUsage;long QuotaPeakNonPagedPoolUsage;long QuotaNonPagedPoolUsage;long PagefileUsage;long PeakPagefileUsage'
Global Const $tagSTORAGE_DEVICE_NUMBER = 'dword DeviceType;ulong DeviceNumber;ulong PartitionNumber'
Global Const $tagTEXTMETRIC = 'long tmHeight;long tmAscent;long tmDescent;long tmInternalLeading;long tmExternalLeading;long tmAveCharWidth;long tmMaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigitizedAspectY;wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmBreakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;byte tmPitchAndFamily;byte tmCharSet'
Global Const $tagWINDOWINFO = 'dword Size;dword rWindow;dword rClient;dword Style;dword ExStyle;dword WindowStatus;uint cxWindowBorders;uint cyWindowBorders;ushort atomWindowType;ushort CreatorVersion'
Global Const $tagDRIVERSTATUS = "byte DriverError;byte IDEStatus;byte Reserved1;dword Reserved2"
Global Const $tagIDEREGS = "byte Features;byte SectorCount;byte SectorNumber;byte CylLow;byte CylHigh;byte DriveHead;byte Command;byte Reserved"
Global Const $tagSTORAGEPROPERTYQUERY = "int PropertyId;int QueryType;byte AdditionalParams"
Global Const $tagSTORAGEDEVICEDESCRIPTOR = "ulong Version;ulong Size;byte DeviceType;byte DeviceTypeModifier;byte RemovableMedia;byte CommandQueueing;ulong VendorIdOffset;ulong ProductIdOffset;ulong ProductRevisionOffset;ulong SerialNumberOffset;int BusType;ulong RawPropertiesLength;byte RawDeviceProperties"
Global Const $tagSENDCMDOUTPARAMS = "dword Size;" & $tagDRIVERSTATUS
Global Const $tagSENDCMDINPARAMS = "dword Size;" & $tagIDEREGS & ";byte DriveNumber;byte Reserved1;dword Reserved2;byte Buffer"
#EndRegion Global Variables and Constants
#Region Local Variables and Constants
Global $__Data, $__RGB = True
#EndRegion Local Variables and Constants
#Region Public Functions
; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_GetDiskSerialNumber
; Description....: Retrieves information about the amount of space that is available on a disk volume.
; Syntax.........: _WinAPI_GetDiskFreeSpaceEx ( $sDrive )
; Parameters.....: $sDrive - The drive to retrieve information, in the format D:, E:, etc.
; Return values..: Success - The array containing the following parameters:
; - The total number of available free bytes on a disk. If per-user quotas are being used, this value
; may be less than the total number of free bytes on a disk.
; - The total number of available bytes on a disk. If per-user quotas are being used, this value
; may be less than the total number of bytes on a disk.
; - The total number of free bytes on a disk.
; Failure - 0 and sets the @error flag to non-zero.
; Author.........: Yashied
; Modified.......:
; Remarks........: None
; Related........:
; Link...........: @@MsdnLink@@ GetDiskFreeSpaceEx
; Example........: Yes
; ===============================================================================================================================
Func _WinAPI_GetDiskSerialNumber($sPhysDisk)
$hDisk = _WinAPI_CreateFile("\\.\" & $sPhysDisk, 2, 6, 6, 1)
If $hDisk = -1 Then
Exit(ConsoleWrite("_WinAPI_CreateFile fails, error code: " & _WinAPI_GetLastError() & @CRLF))
EndIf
$tSCIP = DllStructCreate($tagSENDCMDINPARAMS)
$tSCOP = DllStructCreate($tagSENDCMDOUTPARAMS & ";char Buffer")
$tQuery = DllStructCreate($tagSTORAGEPROPERTYQUERY)
$tDescr = DllStructCreate($tagSTORAGEDEVICEDESCRIPTOR)
DllStructSetData($tQuery, "PropertyId", 0)
DllStructSetData($tQuery, "QueryType", 0)
$iResult = __DeviceIoControl($hDisk, $IOCTL_STORAGE_QUERY_PROPERTY, _
$tQuery, DllStructGetSize($tQuery), _
$tDescr, DllStructGetSize($tDescr))
If $iResult = 0 Then
Exit(ConsoleWrite("_DeviceIoControl fails, error code: " & @error & @CRLF))
EndIf
If DllStructGetData($tDescr, "BusType") = 2 Then
DllStructSetData($tSCIP, "Command", 0xA1)
Else
DllStructSetData($tSCIP, "Command", 0xEC)
EndIf
$iResult = __DeviceIoControl($hDisk, $DFP_RECEIVE_DRIVE_DATA, _
$tSCIP, DllStructGetSize($tSCIP), _
$tSCOP, DllStructGetSize($tSCOP))
If $iResult = 0 Then
Exit(ConsoleWrite("_DeviceIoControl fails, error code: " & @error & @CRLF))
EndIf
Dim $sSerialNum
For $i = 21 to 40 Step 2
$sSerialNum &= DllStructGetData($tSCOP, "Buffer", $i + 1)
$sSerialNum &= DllStructGetData($tSCOP, "Buffer", $i)
Next
$sSerialNum = StringReplace($sSerialNum, " ", "")
$tSCIP = 0
$tSCOP = 0
$tQuery = 0
$tDescr = 0
_WinAPI_CloseHandle($hDisk)
Return $sSerialNum
EndFunc
#EndRegion Public Functions
#Region Internal Functions
Func __MakeCtrlCode($iDevType, $iFunction, $iMethod = 0, $iAccess = 0)
Return bitOR(bitShift($iDevType,-16),bitShift($iAccess, -14),bitShift($iFunction, -2), $iMethod)
EndFunc ;==>_MakeCtrlCode
Func __DeviceIoControl($hDevice, $iCtrlCode, $pIn, $iIn, $pOut, $iOut, $pOverlapped = 0)
Local $iResult
If IsDllStruct($pIn) Then $pIn = DllStructGetPtr($pIn)
If IsDllStruct($pOut) Then $pOut = DllStructGetPtr($pOut)
If IsDllStruct($pOverlapped) Then $pOverlapped = DllStructGetPtr($pOverLapped)
$iResult = DllCall("Kernel32.dll", "int", "DeviceIoControl", "ptr", $hDevice, _
"dword", $iCtrlCode, "ptr", $pIn, "dword", $iIn, _
"ptr", $pOut, "dword", $iOut, "int*", 0, "ptr", $pOverlapped)
Return SetError(_WinAPI_GetLastError(), $iResult, $iResult)
EndFunc ;==>_DeviceIoControl
#EndRegion Internal Functions
回复 5# tttbbb999
你这样用吧,但记住了脚本里千万别include winapiex,要不会冲突的 难怪 Include <WinAPIex.au3>
和Include <Date.au3>
同时出现会报错哦. 原来是这样啊!
页:
[1]