Calling an API Function from DINPUT.Dll Using Delphi Or Pascal

1.5k views Asked by At

I have a program which uses an API from dinput.dll (Direct Input), I have monitored it and the result is this:

API Name: DirectInputCreateEx Module Name: C:\Windows\system32\DINPUT.dll

And about another program which uses Direct Input:

API Name: DirectInputCreateA Module Name: C:\Windows\system32\DINPUT.dll

This API will update this registry key:

HKEY_CURRENT_USER\System\CurrentControlSet\Control\MediaProperties\PrivateProperties\DirectInput

I want to know How can I use Delphi to write a code which ONLY call this API for DirectInput dll?

Any Help is really appreciated...

1

There are 1 answers

9
David Heffernan On BEST ANSWER

In order to call Direct Input you will need a Delphi translation of the header file. The best such translation, to my knowledge, is available from the Clootie graphics pages.

You need to use the DirectInput.pas header translation.

As for writing a program that does not show a Window, here's the simplest template:

program MyProgram;
begin
  //write your program's code here
end.

You state in a comment that the only function you wish to call is DirectInputCreateEx. To call that function you need the following import declaration:

function DirectInputCreateEx(hinst: THandle; dwVersion: DWORD; 
  const riidltf: TGUID; out ppvOut; punkOuter: IUnknown): HResult; 
  stdcall; external 'dinput.dll';