Hi Patrick,
The lazy, but acceptable way to do it is to explictly put the bytes in the
struct. I actually do this in the following example because the string is
only 32 characters. Keep in mind that for the code below, the string is a
TCHAR array not a char array.
Admittedly, this is not pretty but it works:
Original C/C++ declaration:
typedef struct {
WORD wMid;
WORD wPid;
MMVERSION vDriverVersion;
CHAR szPname[MAXPNAMELEN];
DWORD dwFormats;
WORD wChannels;
WORD wReserved1;
DWORD dwSupport;
} WAVEOUTCAPS;
C# Inplementation:
protected class WAVEOUTCAPS
{
public ushort wMid = 0;
public ushort wPid = 0;
public uint vDriverVersion = 0;
// Begin TCHAR szPname[MAXPNAMELEN]
public short b0 = 0;
public short b1 = 0;
public short b2 = 0;
public short b3 = 0;
public short b4 = 0;
public short b5 = 0;
public short b6 = 0;
public short b7 = 0;
public short b8 = 0;
public short b9 = 0;
public short b10 = 0;
public short b11 = 0;
public short b12 = 0;
public short b13 = 0;
public short b14 = 0;
public short b15 = 0;
public short b16 = 0;
public short b17 = 0;
public short b18 = 0;
public short b19 = 0;
public short b20 = 0;
public short b21 = 0;
public short b22 = 0;
public short b23 = 0;
public short b24 = 0;
public short b25 = 0;
public short b26 = 0;
public short b27 = 0;
public short b28 = 0;
public short b29 = 0;
public short b30 = 0;
public short b31 = 0;
// End TCHAR szPname[MAXPNAMELEN]
public uint dwFormats = 0;
public ushort wChannels = 0;
public ushort wReserved1 = 0;
public uint dwSupport = 0;
public string GetProductName()
{
char[] bytes =
{
(char)b0, (char)b1, (char)b2, (char)b3, (char)b4,
(char)b5, (char)b6, (char)b7, (char)b8, (char)b9,
(char)b10, (char)b11, (char)b12, (char)b13, (char)b14,
(char)b15, (char)b16, (char)b17, (char)b18, (char)b19,
(char)b20, (char)b21, (char)b22, (char)b23, (char)b24,
(char)b25, (char)b26, (char)b27, (char)b28, (char)b29,
(char)b30, (char)b31
};
return new string(bytes);
}
--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility