tags:

views:

110

answers:

2

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?

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

+1  A: 

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.

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

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

Shog9
+1  A: 

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

Dustin Campbell
I am suspect of some of the definitions there. They work for 32 bit, but I don't think many of them take 64 bit into account.
Andy Stampor
Just a word of warning, I've found many incorrect definitions on pinvoke.net.
Jon Tackabury