-
September 17th, 2013, 05:32 AM
#1
DllImport issue in C#
Hi.
I need some help on importing a (probably unmanaged) C++ dll. From that specific dll, I only have a header file and a dll.
In the header the following is declared:
Code:
typedef struct Device_ *DeviceHandle;
API ResultType GetDevices(DeviceHandle **devices, UInteger *count);
The definition of Device_ is unknown to me. (It's not in the header file)
I tried the following in C# and it's not giving me an error, but I also don't get a device list and count equals one, even if there are two registered devices connected.
Code:
[DllImport("SomeDLL.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern ErrorType GetDevices(out IntPtr devices, out UInt32 count);
...
var devices = new IntPtr();
UInt32 count = 0;
var result = I1_GetDevices(out devices, out count);
I also have no idea how to use or cast the list of devices.
I appreciate your help!
-
September 17th, 2013, 07:06 AM
#2
Re: DllImport issue in C#
Small addition: it's not C++ but ANSI C99 and Device_ is an opaque struct, so I don't have to use the contents of it, but only use it as an input for other methods
-
September 18th, 2013, 06:27 PM
#3
Re: DllImport issue in C#
See pinvoke.net for pinvoke examples.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|