|
本帖最后由 gz13802424 于 2019-1-10 22:21 编辑
SetupAPI 里面包含了很多很实用的API调用,但是SetupAPI是 11/20/2009 书写的,到现在已经有10年时间了,已经没办法完全匹配到最新的Win10系统
我在日常使用时,把平时自己使用到的几个API调用重新修改了,使之能在Win7 32位(64位)、Win10 32位(64位)下正常使用
并且在这里还要多谢 “haijie1223” 大哥的指点
不多废话了,直接上干货
一、_CM_Get_Process_Heap( “haijie1223” 大哥的指点)
原定义
$iResult = DllCall("Kernel32.dll", "long", "GetProcessHeap")
修改为
$iResult = DllCall("Kernel32.dll", "handle", "GetProcessHeap")
二、_SetupDiEnumDeviceInfo(自己折腾出来的)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 28)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
三、_SetupDiOpenDeviceInfo(自己折腾出来的)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 28)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
四、 _SetupDiCreateDeviceInfo(自己折腾出来的)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 28)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
五、_SetupDiGetDeviceInterfaceDetail(自己折腾出来的)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 28)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
六、_SetupDiOpenDeviceInterface(自己折腾出来的)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 28)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
七、_SetupDiRegisterDeviceInfo(自己折腾出来的)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 28)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
八、_SetupDiCreateDeviceInterface(自己折腾出来的)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 28)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
九、_SetupDiEnumDeviceInterfaces(自己折腾出来的)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 28)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
十、_SetupDiGetClassImageList(自己折腾出来的,一直没直接验证是正确但是也没有异常,这一条的修改我自己标注为 “存疑”)
原定义
DllStructSetData($tSP_DEVINFO_DATA, "Size", 12)
修改为
DllStructSetData($tSP_DEVINFO_DATA, "Size", DllStructGetSize($tSP_DEVINFO_DATA))
--------------------------------------------------- 分 ---- 割 ---- 线 ---------------------------------------------------
P版曾经发了一个AU3书写服务形态的例程,但是没有匹配到64位编译模式,我自己也折腾了一下
原定义
$pServiceTable = _ServiceHeapAlloc(32)
$tServiceTable = DllStructCreate($tagSERVICE_TABLE_ENTRY, $pServiceTable)
DllStructSetData($tServiceTable, "ServiceName", $pServiceTable + 16)
DllStructSetData($tServiceTable, "ServiceMain", $pServiceMain)
$tServiceName = DllStructCreate("char ServiceName[16]", $pServiceTable + 16)
DllStructSetData($tServiceName, "ServiceName", "AutoIt3Service")
$tServiceStatus = DllStructCreate($tagSERVICE_STATUS)
$pServiceStatus = DllStructGetPtr($tServiceStatus)
DllStructSetData($tServiceStatus, "ServiceType", 16)
DllStructSetData($tServiceStatus, "ControlsAccepted", 3)
修改为
$pServiceTable = _ServiceHeapAlloc(32 * (@AutoItX64 + 1))
$tServiceTable = DllStructCreate($tagSERVICE_TABLE_ENTRY, $pServiceTable)
DllStructSetData($tServiceTable, "ServiceName", $pServiceTable + 16 * (@AutoItX64 + 1))
DllStructSetData($tServiceTable, "ServiceMain", $pServiceMain)
$tServiceName = DllStructCreate("char ServiceName[" & 16 * (@AutoItX64 + 1) & "]", $pServiceTable + 16 * (@AutoItX64 + 1))
DllStructSetData($tServiceName, "ServiceName", $sServiceName)
$tServiceStatus = DllStructCreate($tagSERVICE_STATUS)
$pServiceStatus = DllStructGetPtr($tServiceStatus)
DllStructSetData($tServiceStatus, "ServiceType", 16 * (@AutoItX64 + 1))
DllStructSetData($tServiceStatus, "ControlsAccepted", 3)
|
评分
-
查看全部评分
|