Hi Nicholas Paldino ,
The original declaration is
typedef struct TBufferHeader_tag
{
PK_PCHAR lpData;
PK_U32 dwBufferLength;
PK_U32 dwBytesRecorded;
PK_U32 dwUser;
PK_U32 dwFlags;
PK_U32 dwTimeStamp;
struct TBufferHeader_tag *lpNext;
PK_U32 reserved;
} TBufferHeader, *PBufferHeader;
The functon my program are going to call is
Syntax
PK_STATUS PK_AUDIO_InputAddBuffer
(
IN TResourceHandle hPort, // TResourceHandle is an int
IN PBufferHeader pBuffer
);
I am trying to use
[DllImport("PikaAPI.dll")]
unsafe public static extern int PK_AUDIO_InputAddBuffer(uint
TResourceHandle, TBufferHeader *pBuffer);
But I got errors when I compiled
Cannot take the address or size of a variable of a managed type
(TBufferHeader)
Thanks for any help
Kathy Tran
Nicholas Paldino said:
Kathy,
What is the original declaration (in C/C++) of the method? The one that
you have is not an array of pointers, but rather, just a pointer to the
structure, which is the same as an array of structures (not an array of
pointers to a structure).
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Kathy Tran said:
Hi Nicholas Paldino ,
Thanks for responding my question. I am performing some of interop which
requires an array of pointers to these structures to be taken. In my
program
I want to go through an array of pointer, with each element in array I
assign
some values in structure and then pass each element to un unmanaged code
function
[DllImport("PikaAPI.dll")]
unsafe public static extern int PK_AUDIO_InputAddBuffer(SEventQ *pEvent);
but I am very confusing and do not how to declare an array of pointer.
Thank,
Kathy Tran
:
Kathy,
Why do you want an array of pointers. Are you performing some sort
of
interop which requires an array of pointers to these structures to be
taken,
or do you need an array of structure?
If you wanted an array of pointers, I believe you would do:
SEventQ **EvQ;
However, you couldn't say "new SEventQ*", since you can't "create" a
pointer in that manner.
What is it that you are trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hi,
Could you please help me how to declare an araay of pointer in C#.
In my program I declared an structure
public struct SEventQ
{
public uint uiUserData;
public uint uiEvent;
public uint uiParam0;
public uint uiParam1;
}
Now I want to delare an array of pointer look likes
unsafe SEventQ [] *EvQ = new SEventQ[10];
Thanks,
Kathy Tran