在哪里可以找到解释如何使用C / C ++函数头并在C#中使用dllimport定义它的参考?

时间:2022-04-24 05:11:27

I am using setupapi.dll to determine USB device connectivity. It isn't working properly in 64 bit versions of windows (XP, Vista). I suspect that the declarations are not quite correct, but am not sure how to verify. MS doesn't seem to provide the dllimport information, but they do list all the function definitions. Is there a resource I can use to convert between the function header and the dllimport declaration?

我正在使用setupapi.dll来确定USB设备连接。它在64位版本的Windows(XP,Vista)中无法正常工作。我怀疑声明不太正确,但我不确定如何验证。 MS似乎没有提供dllimport信息,但它们列出了所有函数定义。是否有可用于在函数头和dllimport声明之间进行转换的资源?

I've used pinvoke.net, but it looks like it doesn't account for 64 bit in the definitions provided.

我使用过pinvoke.net,但看起来它在提供的定义中没有占64位。

2 个解决方案

#1


Check out pinvoke.net. It has a large set of Win32 APIs already translated to DllImport definitions (Including setupapi.dll).

看看pinvoke.net。它有一大堆已经转换为DllImport定义的Win32 API(包括setupapi.dll)。

#2


The tool you're looking for is called C++/CLI. It was built to process those headers and generate interop code - no mucking around with P/Invoke.

您正在寻找的工具称为C ++ / CLI。它是为处理这些标题并生成互操作代码而构建的 - 没有用P / Invoke来解决问题。

Write a light-weight wrapper assembly in C++/CLI, and then use it from your C# code.

在C ++ / CLI中编写一个轻量级的包装器程序集,然后从C#代码中使用它。

(Hard to provide a more specific answer, since you didn't really specify how it's not working properly...)

(很难提供更具体的答案,因为你没有真正说明它是如何不能正常工作......)

#1


Check out pinvoke.net. It has a large set of Win32 APIs already translated to DllImport definitions (Including setupapi.dll).

看看pinvoke.net。它有一大堆已经转换为DllImport定义的Win32 API(包括setupapi.dll)。

#2


The tool you're looking for is called C++/CLI. It was built to process those headers and generate interop code - no mucking around with P/Invoke.

您正在寻找的工具称为C ++ / CLI。它是为处理这些标题并生成互操作代码而构建的 - 没有用P / Invoke来解决问题。

Write a light-weight wrapper assembly in C++/CLI, and then use it from your C# code.

在C ++ / CLI中编写一个轻量级的包装器程序集,然后从C#代码中使用它。

(Hard to provide a more specific answer, since you didn't really specify how it's not working properly...)

(很难提供更具体的答案,因为你没有真正说明它是如何不能正常工作......)