Jump to content

[Solved]DirectInput8Create problem


Frenchy
 Share

Recommended Posts

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 *)

#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 by Frenchy
Link to comment
Share on other sites

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 by Frenchy
Link to comment
Share on other sites

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 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

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

:argue:

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 by Frenchy
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...