AutoIt의 DLLCall에 문제가 있습니다.AutoIt DllCall to USB
AutoIT를 사용하여 Delcom USB 표시기 LED 라이트를 제어하려고합니다.
DelcomGetDeviceCount :이 작업을 수행하기 위해, 나는 다음과 같은 기능을 포함하는 .DLL이 지정된 장치 유형에 대한 검색, 취득 장치 이름의 문자열
DelcomOpenDevice : DELCOM USB 장치의 수
DelcomGetNthDevice을 반환 : 디바이스 명을 얻어 되돌아가 USB 디바이스에 처리
DelcomLEDControl : USB 핸들 걸리는 LED
상태 여기에 docum a link이다 설정 이러한 DLL 기능에 대한 권한 부여.
DelcomGetDeviceCount를 사용하여 하나의 장치를 검색하더라도 DelcomGetNthDevice에 대한 호출이 0을 반환하므로 장치를 찾지 못해서 내 문제가 올바르게 장치 이름에 포인터를 포맷하지 않는다고 생각합니다.
나는
Local $handleDLL = DLLOpen("C:\DelcomDLL.dll")
Local $stString = DllStructCreate("wchar Name[512]")
Local $devices = DllCall($handleDLL,"dword","DelcomGetDeviceCount","dword",0)
Local $result = DllCall($handleDLL,"dword","DelcomGetNthDevice","dword",1,"dword",0,"ptr",DllStructGetPtr($stString))
Local $handleUSB = DllCall($handleDLL,"handle","DelcomOpenDevice","str",DllStructGetData($stString,"Name"),"dword",0)
Local $result2 = DllCall($handleDLL,"dword","DelcomLEDControl","handle",$handleUSB[0],"dword",0,"dword",1)
MsgBox(0,"# of Devices",$devices[0])
MsgBox(0,"Bool Found Device",$result[0])
DllClose($handleDLL)
및
Local $handleDLL = DLLOpen("C:\Users\b46020\Documents\Asher Project\DelcomDLL.dll")
Local $stString
Local $devices = DllCall($handleDLL,"dword","DelcomGetDeviceCount","dword",0)
Local $result = DllCall($handleDLL,"dword","DelcomGetNthDevice","dword",1,"dword",0,"str*",$stString)
Local $handleUSB = DllCall($handleDLL,"handle","DelcomOpenDevice","str*",$stString,"dword",0)
Local $result2 = DllCall($handleDLL,"dword","DelcomLEDControl","handle",$handleUSB[0],"dword",0,"dword",1)
MsgBox(0,"# of Devices",$devices[0])
MsgBox(0,"Bool Found Device",$result[0])
DllClose($handleDLL)
을 시도했지만 각각의 경우에 나는 1 개 장치를 설정하지만, 그 이름을 얻을 수 없습니다.
감사합니다.
덕분에, 조나단
두 가지가 첫 번째 예에서 잘못 표시, 당신은 AutoIt이이 작업을 수행해야하지만 (매우 다른 종류 [] 및 STR를 WCHAR 믹싱 이 경우 귀하를위한 전환). 이것을 확인하기 위해 헤더 파일에 대한 링크가 필요 하겠지만, 문자열에 대한 포인터의 배열이 아니라 문자열에 대한 포인터를 전달하는 것처럼 보입니다. 나는 당신에게 모든 장치의 이름을 줄 수 있어야한다고 생각하는 것을 빨리 썼다. 물론 나는 그것을 시험 할 수 없다. https://gist.github.com/MattDiesel/5862545 – Matt
네, 감사합니다. Matt, 장치 이름을 바꿨습니다. char []로 바꾸면 효과가있었습니다. – MrInvertible
잘 보니 반갑습니다. – Matt