Frenchy Posted December 26, 2012 Share Posted December 26, 2012 (edited) Hi, some help will be appreciate!! I have problem with the call of function DirectInput8Create: Local $aCall = DllCall($hDINPUT, "long", "DirectInput8Create", "handle", $h , "dword", $DIRECTINPUT_VERSION, "ptr", DllStructGetPtr($pIID), "ptr", $p, "ptr", 0) I have this error : Pointer that is not valid 0x80004003 the function in C++ is: HRESULT DirectInput8Create( HINSTANCE hinst,DWORD dwVersion,REFIID riidltf,LPVOID * ppvOut,LPUNKNOWN punkOuter ) I think i have an error about the definition of ppvout (LPVOID *) expandcollapse popup#include "AutoitObject.au3" #include "WINAPI.au3" Opt("GUIOnEventMode", 1) ; Error monitoring Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF) Return EndFunc ;==>_ErrFunc ; DirectInput related constants Global Const $DIRECTINPUT_VERSION = 0x0800 Global const $sIID_IDirectInputDevice8W = "{54D41081-DC15-4833-A41B-748F73A38179}" ; Used Dlls Global Const $hD3D9 = DllOpen("d3d9.dll") Global Const $hDINPUT = DllOpen("dinput8.dll") Global Const $hUSER32 = DllOpen("user32.dll") Global Const $hKERNEL32 = DllOpen("kernel32.dll") ; Start the AutoItObject library _AutoItObject_StartUp() ; GUI Global Const $hGUI = GUICreate("DirectI -- Direct3D/AutoitObject", 400, 400) ; IDirect3D9 interface pointer ;Global $pD3D9 = _Direct3DCreate9() ; IDirectInput interface pointer Local $pIDirectInput8 Global $p _DirectInput8create() Exit ;~ Global $tagIDirectInput8W = "CreateDevice;" & _ ;~ "EnumDevices;" & _ ;~ "GetDeviceStatus;" & _ ;~ "RunControlPanel;" & _ ;~ "Initialize;" & _ ;~ "FindDevice;" & _ ;~ "EnumDevicesBySemantics;" & _ ;~ "ConfigureDevices;" ;~ Global $oDINPUT = _AutoItObject_WrapperCreate($pDINPUT, $tagIDirectInput8W) ; DirectInput functions: Func _DirectInput8create() Local $pIID = _AutoItObject_CLSIDFromString($sIID_IDirectInputDevice8W) Local $h = _WinAPI_GetModuleHandle("") Local $aCall = DllCall($hDINPUT, "long", "DirectInput8Create", "handle", $h , "dword", $DIRECTINPUT_VERSION, "ptr", DllStructGetPtr($pIID), "ptr", $p, "ptr", 0) MsgBox(0,@error,Hex($aCall[0],8)) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) EndIf Return $aCall[0] EndFunc ;==>_Direct3DCreate9 ; On Exit Function Func _Quit() $oD3D9Vertex = 0 $oD3DDevice9 = 0 $oD3D9 = 0 Exit EndFunc ;==>_Quit Thanks Thierry Edited December 29, 2012 by Frenchy Link to comment Share on other sites More sharing options...
trancexx Posted December 26, 2012 Share Posted December 26, 2012 (edited) Parameter before the last one should be defined as:"ptr*", 0 ...Then you read from returned DllCall() array like this:$p = $aCall[4] Edited December 26, 2012 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Frenchy Posted December 26, 2012 Author Share Posted December 26, 2012 (edited) Thanks trancexx for your reply, i have tested with your modifications which seems good,Local $aCall = DllCall($hDINPUT, "long", "DirectInput8Create", "handle", $h , "dword", $DIRECTINPUT_VERSION, "ptr", DllStructGetPtr($pIID), "ptr*", 0, "ptr", 0)but now i have another error -> "0x80004002 -> No such interface supported"Have you tested the code and no error for you?Thierry Edited December 26, 2012 by Frenchy Link to comment Share on other sites More sharing options...
JohnOne Posted December 26, 2012 Share Posted December 26, 2012 (edited) I think the param trancexx mentioned, (second to last) is your out param (ppvOut) and should be a pointer to pointer. Right now you are passing a pointer to riidltf where it does not require one and a null pointer to ppvOut Edited December 26, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Frenchy Posted December 27, 2012 Author Share Posted December 27, 2012 Hi John,REFIID structure is long,shor,short,byte[8], so in the dllcall, its necessary a pointer not a value..?so the problem is always there..i would use the_AutoItObject_DllOpen but when i am testing the sample given in the help file..nothings is functional...??? i have to register or not some dll maybe?? Link to comment Share on other sites More sharing options...
trancexx Posted December 27, 2012 Share Posted December 27, 2012 Docummentation for DirectInput8Create says that third param is IID_IDirectInput8. You are passing IID_IDirectInputDevice8. I don't see why to be surprised if your call fails. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Frenchy Posted December 27, 2012 Author Share Posted December 27, 2012 (edited) Yes i just see that. stupid error ..you are quicker than me...thanks...all is okay now i have the right return!!..i follow the way... with : Global const $sIID_IDirectInput8W = "{BF798031-483A-4DA2-AA99-5D64ED369700}" it s better Edited December 27, 2012 by Frenchy Link to comment Share on other sites More sharing options...
trancexx Posted December 27, 2012 Share Posted December 27, 2012 Ok. I'm glad you've got it working. You know, you don't need AutoItObject for this. AutoIt has built-in ObjCreateInterface() funcion that does the job you need much better and simpler. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Frenchy Posted December 27, 2012 Author Share Posted December 27, 2012 Thanks Trancexx, i have found the CLSID of dinput8.dll (registry key) and i have the same result ...with less code.. Link to comment Share on other sites More sharing options...
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