I am trying to call into a C DLL (fglove.dll) using C#.
I would like to call the fdOpen and fdClose methods. I have included
some of the header file.
I am really new to this, so any help would be great.
typedef struct
{
// The contents of this struct are platform-dependent and subject to
// change. You should not manipulate the contents of this struct
directly.
void *m_pStuff;
} fdGlove;
/*--------------------------------------------------------------------------*/
fdGlove *fdOpen(char *pPort);
int fdClose(fdGlove *pFG);
Thanks,
John
> typedef struct
> {
[quoted text clipped - 3 lines]
> void *m_pStuff;
> } fdGlove;
/*----------------------------------------------------------
----------------*/
> fdGlove *fdOpen(char *pPort);
> int fdClose(fdGlove *pFG);
Did you even try to read the documentation on P/Invoke and
the samples in the SDK? This should be what you need:
using System;
using System.Runtime.InteropServices;
public class fglove
{
[
DllImport(
"fglove.dll",
CallingConvention=CallingConvention.Cdecl,
ExactSpelling=true,
CharSet=CharSet.Ansi)
]
public static extern IntPtr fdOpen(string pPort);
[
DllImport(
"fglove.dll",
CallingConvention=CallingConvention.Cdecl,
ExactSpelling=true,
CharSet=CharSet.Ansi)
]
public static extern int fdClose(IntPtr pFG);
}
Since the .h you posted states that you should not know
what's inside an fdGlove struct, you can just reference it
through an opaque pointer.

Signature
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net