J
J
I'm at a loss on how to accomplish one item with C# entirely in
managed code -- I'd like to make a call to a Win32 function, one of
its parameters is a structure that contains a pointer to one or more
structures. How do I setup the structure in C# to allow for the
pointer to a structure?
The structure that I'm referring to is MIXERLINECONTROLS and it's
declaration is the following:
typedef struct {
DWORD cbStruct;
DWORD dwLineID;
union {
DWORD dwControlID;
DWORD dwControlType;
};
DWORD cControls;
DWORD cbmxctrl;
LPMIXERCONTROL pamxctrl;
} MIXERLINECONTROLS;
For the API that I want to use, it requires that the pamxctrl member
must point to the first MIXERCONTROL structure to be filled.
I can map out most of the C++ struct into the C# equivalent to be able
to do this fully in managed code so it looks like this:
[ StructLayout( LayoutKind.Sequential )]
public struct MIXERLINECONTROLS
{
public uint cbStruct; /* uint is DWORD in C++ */
public uint dwLineID;
union {
public uint dwControlID;
public uint dwControlType;
};
public uint cControls;
public uint cbmxctrl;
LPMIXERCONTROL pamxctrl; //<< **HOW DO I CONVERT THIS INTO C#? >>
};
When I call the Win32API that makes use of the MIXERLINECONTROLS
struct, I'm not sure how to set up
1) the pointer to the structure that's necessary in the definition of
the struct for C#
2) the allocation of the correct amount of memory for pamxctrl before
I pass it into the call
so that I can get back the list of array items of MIXERCONTROL
3) the accessing of the list of array items of pamxctrl that I get
back from the call.
Could someone point out some suggestions for me? I'd really appreciate
it.
Thanks in advance,
J
managed code -- I'd like to make a call to a Win32 function, one of
its parameters is a structure that contains a pointer to one or more
structures. How do I setup the structure in C# to allow for the
pointer to a structure?
The structure that I'm referring to is MIXERLINECONTROLS and it's
declaration is the following:
typedef struct {
DWORD cbStruct;
DWORD dwLineID;
union {
DWORD dwControlID;
DWORD dwControlType;
};
DWORD cControls;
DWORD cbmxctrl;
LPMIXERCONTROL pamxctrl;
} MIXERLINECONTROLS;
For the API that I want to use, it requires that the pamxctrl member
must point to the first MIXERCONTROL structure to be filled.
I can map out most of the C++ struct into the C# equivalent to be able
to do this fully in managed code so it looks like this:
[ StructLayout( LayoutKind.Sequential )]
public struct MIXERLINECONTROLS
{
public uint cbStruct; /* uint is DWORD in C++ */
public uint dwLineID;
union {
public uint dwControlID;
public uint dwControlType;
};
public uint cControls;
public uint cbmxctrl;
LPMIXERCONTROL pamxctrl; //<< **HOW DO I CONVERT THIS INTO C#? >>
};
When I call the Win32API that makes use of the MIXERLINECONTROLS
struct, I'm not sure how to set up
1) the pointer to the structure that's necessary in the definition of
the struct for C#
2) the allocation of the correct amount of memory for pamxctrl before
I pass it into the call
so that I can get back the list of array items of MIXERCONTROL
3) the accessing of the list of array items of pamxctrl that I get
back from the call.
Could someone point out some suggestions for me? I'd really appreciate
it.
Thanks in advance,
J