advanced? marshaling

J

jeroen

Question,

I spend this day in trying to convert the following structures to c# for use
in a p/invoke but i'm keep getting a system.notsupportedexception which
means that there is something wrong with my c# code. Expecially the static
TCHAR array gives me a headache, frankly i'm not sure how to do it in c#.
Anybody got an idea ?

thanks in advance Jeroen


typedef struct _CONNMGR_DESTINATION_INFO {
GUID guid;
TCHAR szDescription[128];
} CONNMGR_DESTINATION_INFO;

typedef struct _CONNMGR_CONNECTIONINFO {
DWORD cbSize;
DWORD dwParams;
DWORD dwFlags;
DWORD dwPriority;
BOOL bExclusive;
BOOL bDisabled;
GUID guidDestNet;
HWND hWnd;
UINT uMsg;
LPARAM lParam;
ULONG ulMaxCost;
ULONG ulMinRcvBw;
ULONG ulMaxConnLatency;
} CONNMGR_CONNECTIONINFO;

typedef struct _GUID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
 
G

Geoff Schwab [MSFT]

Hi Jeroen,

The best way to take care of the TCHAR array is to create a class that has a
byte array as its data and accesses the members as properties. For an
example, see the WAVEOUTCAPS class in the following sample:

Recording and Playing Sound with the Waveform Audio Interface
http://msdn.microsoft.com/library/en-us/dnnetcomp/html/WaveInOut.asp

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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