C Dll Struct -> Vb.Net Structure

M

MobileDeveloper

Good day.

I am developing a mobile application in Vb.Net 2003 that runs on a
windows CE.Net mobile device. The device came with a whole bunch of c
dll's from the manufacturers. I have the c header files (.h) and after
much research, I learned that the function names in the actual dlls
were "mangled".
Using "dumpbin.exe /exports" I managed to get the actual function
names and call them. Now my problem is that I'm not too clued up on C
to be able to convert the struct's to VB structures.

As an example, lets work with: sgFingerPrintDevice.dll
In the header file, one of the functions is defined as:
DI_FP_DLL UINT DIFingerprint_GetVersion(VOID);

This is how I reference it from my mobile application:
Public Declare Function DIFingerprint_GetVersion Lib
"sgFingerPrintDevice.Dll" Alias "?DIFingerprint_GetVersion@@YAIXZ" ()
As Integer

I can call this function and get the version without problems.

The next function in the dll is:
DI_FP_DLL STATUS_CODE DIFingerprint_OpenDevice
(fingerprintDeviceSTRUCT* fingerprintInfo);

struct fingerprintDeviceSTRUCT
{
DWORD dwSize;

HANDLE hDevice;
VOID* pDeviceInfo;

BOOL fIsListening;
BOOL fIsScanning;

HWND hwndTarget;
UINT nTargetMessageID;

BOOL (*GetImage) (VOID* pInfo, VOID* pBuffer, UINT* pnSize);
BOOL (*ChangeSetting) (VOID* pInfo,
UINT nID,
VOID* pValue,
UINT nValueSize);
};


What I need is the Vb structure of this C struct, and more
importantly, a way to convert any other structure - other than posting
all the header files and expecting someone to do it for me.

Something like:
Public Structure fingerprintDeviceSTRUCT
Dim dwSize As String
...
End Structure

Thank you.
 
C

Chris Tacke, eMVP

That looks like it's got function pointers in the struct, which are
impossible with the CF. Now if they are unused by the API that you pass the
struct to you could pass them as IntPtr.Zero. These mappings may help:

DWORD -> UInt32
HANDLE -> UInt32 or IntPtr
BOOL ->Integer
HWND -> UInt32 or IntPtr
UINT ->UInt32
Function Pointers -> IntPtr.Zero for NULL, otherwise unsupported
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top