I am currently calling a 3rd party external library using P/Invoke.
The library gives me a handful of functions that I need to call. I
have been successful at calling many of them, but I am some trouble
calling a certain function that requires a pointer to a pointer. Here
is the relevant header information:
typedef struct _ITEM_INFO
{
int itemID;
int itemValue;
} ITEM_INFO;
typedef struct _ITEMS
{
int count; /* number of items */
ITEM_INFO * itemList; /* list of iteminfo */
} ITEMS;
RESULT_CODE WINAPI GetItemList(ITE MS ** itemList);
I need a way to call the GetItemList. In the end, I need the list of
itemIDs and their associated values. I found an article on a technique
for calling a pointer to a pointer to a struct at
http://www.vsj.co.uk/articles/display.asp?id=501. That technique used
the Marshal.AllocHG lobal and Marshal.Structu reToPtr methods, but the
Marshal.AllocHG lobal requires a size parameter for the ITEMS structure.
However, this structure does not have a constant size due to the list
inside of it. Does anyone know how I might be able to call this
function from C#?
Thanks for your help.
Jim