lhhrune Posted May 13, 2008 Posted May 13, 2008 Hi, I'm new to autoit scripting, but i want to learn a bit more about dllcalls... Made some calls work already, but now i'm stuck...so if someone knows how to do this please let me know.. below the syntax as it is on msdn..it's a psapi.dll call BOOL WINAPI EnumDeviceDrivers( __out LPVOID* lpImageBase, __in DWORD cb, __out LPDWORD lpcbNeeded ); Can someone show me how to convert this to a autoit dllcall?? Thanks in advance..
danielkza Posted May 13, 2008 Posted May 13, 2008 Working Example,enumerate all device drivers(by that i mean their files) from the system.Asking anything u need. Tested in last RC. expandcollapse popup#include <GUIConstantsEx.au3> Global Const $MAX_DRIVERS = 1024 Global Const $MAX_DRIVER_NAME = 256 ; Get Pointer size depending on the system's architeture If @AutoItX64 Then Global $LPVOID_SIZE = 8 Else GLobal $LPVOID_SIZE = 4 EndIF $tDriverArray = DllStructCreate("ptr[" & $MAX_DRIVERS & "]") $tDriverNeeded = DllStructCreate("dword") $Ret = DllCall("psapi.dll","int","EnumDeviceDrivers", _ "ptr",DllStructGetPtr($tDriverArray), _ "dword",DllStructGetSize($tDriverArray), _ "ptr",DllStructGetPtr($tDriverNeeded)) If @error OR NOT $Ret[0] THen MsgBox(16,"PSAPI.DLL","Error calling EnumDeviceDrivers") Exit EndIf $iDriverCount = DllStructGetData($tDriverNeeded,1) / $LPVOID_SIZE MsgBox(0,"Driver Count",$iDriverCount) $szDrivers = "" IF $iDriverCount <= $MAX_DRIVERS Then For $i=1 To $iDriverCount $szDrivers &= GetDeviceDriverBaseName(DllStructGetData($tDriverArray,1,$i)) & @CRLF Next $GUI = GUICreate("",500,500) $Edit = GUICtrlCreateEdit($szDrivers,15,15,470,470) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Else MSgBox(16,"PSAPI.DLL","Error : Buffer too small for all drivers.") EndIf Func GetDeviceDriverBaseName(Const $pDriver) $tDriverName = DllStructCreate("char[" & $MAX_DRIVER_NAME & "]") $Ret = DllCall("psapi.dll","int","GetDeviceDriverBaseName", _ "ptr",$pDriver, _ "ptr",DllStructGetPtr($tDriverName), _ "dword",DllStructGetSize($tDriverName)) If @error OR NOT $Ret[0] Then Return SetError(1,0,"") Else Return DllStructGetData($tDriverName,1) EndIf EndFUnc
lhhrune Posted May 13, 2008 Author Posted May 13, 2008 thanks for ur quick reply, it works perfectly, so now i'm going to have a look how u did it
danielkza Posted May 13, 2008 Posted May 13, 2008 thanks for ur quick reply, it works perfectly, so now i'm going to have a look how u did it All the information was obtained from MSDN, exactly from here:EnumDeviceDriversand here:GetDeviceDriverBaseName
lhhrune Posted May 13, 2008 Author Posted May 13, 2008 yeah i know, i was more messing around how to get it 'translated' to autoit, but it is slowly becoming clear to me Thanks
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now