找回密码
 加入
搜索
查看: 2327|回复: 6

[网络通信] 【已解决】<DriveGetSerial.au3>和<GDIPlus.au3>冲突!

[复制链接]
发表于 2019-6-15 18:55:30 | 显示全部楼层 |阅读模式
本帖最后由 cihron 于 2019-6-22 22:01 编辑
#include <DriveGetSerial.au3>
#Include <GDIPlus.au3>
程序中同时引用这两个头文件时会发生冲突,有谁遇到过?


报错信息:
"C:\Autoit3\Include\WinAPIInternals.au3"(23,171) : error: $tagOSVERSIONINFO 上一次定义为一个 'Const' 变量..
Global Const $tagOSVERSIONINFO = 'struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Autoit3\Include\WinAPIGdi.au3"(20,148) : error: $tagBITMAP 上一次定义为一个 'Const' 变量..
Global Const $tagBITMAP = 'struct;long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;endstruct'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Autoit3\Include\WinAPIGdi.au3"(25,126) : error: $tagDIBSECTION 上一次定义为一个 'Const' 变量..
Global Const $tagDIBSECTION = $tagBITMAP & ';' & $tagBITMAPINFOHEADER & ';dword dsBitfields[3];ptr dshSection;dword dsOffset'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Autoit3\Include\WinAPIGdi.au3"(28,147) : error: $tagEXTLOGPEN 上一次定义为一个 'Const' 变量..
Global Const $tagEXTLOGPEN = 'dword PenStyle;dword Width;uint BrushStyle;dword Color;ulong_ptr Hatch;dword NumEntries' ; & ';dword StyleEntry[n];'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Autoit3\Include\WinAPIGdi.au3"(31,69) : error: $tagLOGBRUSH 上一次定义为一个 'Const' 变量..
Global Const $tagLOGBRUSH = 'uint Style;dword Color;ulong_ptr Hatch'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Autoit3\Include\WinAPIGdi.au3"(32,63) : error: $tagLOGPEN 上一次定义为一个 'Const' 变量..
Global Const $tagLOGPEN = 'uint Style;dword Width;dword Color'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Autoit3\Include\WinAPIGdi.au3"(38,118) : error: $tagPAINTSTRUCT 上一次定义为一个 'Const' 变量..
Global Const $tagPAINTSTRUCT = 'hwnd hDC;int fErase;dword rPaint[4];int fRestore;int fIncUpdate;byte rgbReserved[32]'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"F:\code\test.au3"(41,34) : warning: $Label1: 使用前并未进行声明.
        $nRet = GUICtrlSetImage( $Label1,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"F:\code\test.au3"(41,55) : warning: $_FILE_VERIFY_PIC1: 使用前并未进行声明.
        $nRet = GUICtrlSetImage( $Label1, $_FILE_VERIFY_PIC1 )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"F:\code\test.au3"(42,34) : warning: $Label2: 使用前并未进行声明.
        $nRet = GUICtrlSetImage( $Label2,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"F:\code\test.au3"(42,55) : warning: $_FILE_VERIFY_PIC2: 使用前并未进行声明.
        $nRet = GUICtrlSetImage( $Label2, $_FILE_VERIFY_PIC2 )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"F:\code\test.au3"(41,34) : error: $Label1: 未声明的全局变量.
        $nRet = GUICtrlSetImage( $Label1,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"F:\code\test.au3"(41,55) : error: $_FILE_VERIFY_PIC1: 未声明的全局变量.
        $nRet = GUICtrlSetImage( $Label1, $_FILE_VERIFY_PIC1 )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"F:\code\test.au3"(42,34) : error: $Label2: 未声明的全局变量.
        $nRet = GUICtrlSetImage( $Label2,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"F:\code\test.au3"(42,55) : error: $_FILE_VERIFY_PIC2: 未声明的全局变量.
        $nRet = GUICtrlSetImage( $Label2, $_FILE_VERIFY_PIC2 )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

发表于 2019-6-15 20:08:11 | 显示全部楼层
有 DriveGetSerial.au3 这个头文件?没见过~ DriveGetSerial 就是一个内置函数…
发表于 2019-6-15 22:29:58 | 显示全部楼层
可能是版本原因,GDI大神seniors在http://www.autoitx.com/forum.php?mod=viewthread&tid=38862中给出的示例代码,直接用3.3.14.2也有常量冲突,把自己需要的函数复制出来。再手动赋上原au3中的常量,不用include引用整个文件就好了。
 楼主| 发表于 2019-6-16 10:05:45 | 显示全部楼层
查了一下所引用的 DriveGetSerial.au3 库,确实不是标准库,不知从哪里引用的,导致运行冲突。

手工修改 DriveGetSerial.au3 内部定义的变更名称,问题解决!

发此文件,供大家参考。

#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'
;lobal 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[1]'
Global Const $tagDIBSECTION = $tagBITMAP & ';' & $tagBITMAPINFOHEADER & ';dword dsBitfields[3];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[n]'
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[128];dword State;dword StateMask;wchar Info[256];uint Version;wchar InfoTitle[64];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[260];wchar TypeName[80]'
Global Const $tagOSVERSIONINFO = 'dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128]'
Global Const $tagOSVERSIONINFOEX = $tagOSVERSIONINFO & ';short ServicePackMajor;short ServicePackMinor;short SuiteMask;byte ProductType;byte Reserved'
Global Const $tagPAINTSTRUCT = 'hwnd hDC;int fErase;dword rPaint[4];int fRestore;int fIncUpdate;byte rgbReserved[32]'
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'
;lobal 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[4];dword rClient[4];dword Style;dword ExStyle;dword WindowStatus;uint cxWindowBorders;uint cyWindowBorders;ushort atomWindowType;ushort CreatorVersion'
Global Const $tagDRIVERSTATUS = "byte DriverError;byte IDEStatus;byte Reserved1[2];dword Reserved2[2]"
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[3];dword Reserved2[4];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:
;                            [0] - 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.
;                            [1] - 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.
;                            [2] - 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[1024]")
$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[7], $iResult[0])
EndFunc    ;==>_DeviceIoControl

#EndRegion Internal Functions

;程序调用方法
;MsgBox(0,"",_Winapi_GetDiskSerialNumber("D:"))
 楼主| 发表于 2019-6-16 10:58:50 | 显示全部楼层
afan 发表于 2019-6-15 20:08
有 DriveGetSerial.au3 这个头文件?没见过~ DriveGetSerial 就是一个内置函数…

问题已经解决,感谢!!!
 楼主| 发表于 2019-6-16 11:01:08 | 显示全部楼层
zch11230 发表于 2019-6-15 22:29
可能是版本原因,GDI大神seniors在http://www.autoitx.com/forum.php?mod=viewthread&tid=38862中给出的示 ...

问题已经解决,感谢!!!
发表于 2019-6-18 10:42:00 | 显示全部楼层
不错支持一下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-16 10:53 , Processed in 0.072360 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表