【问题标题】:Calling an API Function from DINPUT.Dll Using Delphi Or Pascal使用 Delphi 或 Pascal 从 DINPUT.Dll 调用 API 函数
【发布时间】:2012-01-11 15:36:50
【问题描述】:

我有一个使用来自 dinput.dll(直接输入)的 API 的程序,我对其进行了监控,结果如下:

API 名称:DirectInputCreateEx 模块名称:C:\Windows\system32\DINPUT.dll

关于另一个使用直接输入的程序:

API 名称:DirectInputCreateA 模块名称:C:\Windows\system32\DINPUT.dll

此 API 将更新此注册表项:

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

我想知道如何使用 Delphi 编写只为 DirectInput dll 调用此 API 的代码?

非常感谢任何帮助...

【问题讨论】:

标签: delphi directinput


【解决方案1】:

为了调用直接输入,您需要对头文件进行 Delphi 翻译。据我所知,最好的此类翻译可从Clootie graphics pages 获得。

您需要使用DirectInput.pas 标头翻译。

至于写一个不显示窗口的程序,这里是最简单的模板:

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

您在评论中声明您希望调用的唯一函数是DirectInputCreateEx。要调用该函数,您需要以下导入声明:

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

【讨论】:

  • 需要句号而不是分号
  • 抱歉,我做不到。我怎么会知道你写了什么?你没有说你想做什么。自己动手,遇到困难时寻求帮助。
  • 好的,你的回答对我有很大帮助 :) 我稍微改变了我的问题 :)
  • 你的问题对我来说越来越不清楚了。我回答了如何从 Delphi 调用 DirectInput,但现在你在谈论注册表?我很困惑。
  • 嗨大卫,我只想使用来自 dinput.dll 的 DirectInputCreateEx API,我不想使用任何其他 API,我认为 Direct Input 头文件有太多额外的 API。我只是一个使用一个,没有使用任何额外的信息和任何额外的直接 x API。该怎么做?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-13
  • 1970-01-01
  • 2017-05-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多