Sign in to follow this  
Followers 0
Frenchy

[Solved]DirectInput8Create problem

9 posts in this topic

#1 ·  Posted (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 *)

#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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Frenchy

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
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??

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

: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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thanks Trancexx, i have found the CLSID of dinput8.dll (registry key) and i have the same result ...with less code..

Share this post


Link to post
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
Sign in to follow this  
Followers 0