[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Using (char *) in a structure

Francois PIETTE

10/2/2003 8:46:00 AM

I have to call an API function (unmanaged code in a win32 DLL).
The API function fill a structure like this:

typedef struct _MYSTRUCT
{
UINT Version;
char* Info;
} MYSTRUCT;

The API function takes as argument a pointer to the structure. I can pass it
correctly to the API (I'm sure because the version number is correctly
initialized). But I don't know how to access the Info member to copy his
value to a managed string. It is the API that allocate the memory (actually
just a pointer to a static variable) for the Info member.

Can someone show some actual code ?

--
francois.piette@overbyte.be
http://www.o...



2 Answers

(Mattias Sjögren)

10/2/2003 8:47:00 PM

0

Francois,

>Can someone show some actual code ?

Make the Info member an IntPtr in managed code, and use
Marshal.PtrToStringAnsi to retrieve the string after the call.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.n...
Please reply only to the newsgroup.

Francois PIETTE

10/3/2003 8:48:00 AM

0

> Make the Info member an IntPtr in managed code, and use
> Marshal.PtrToStringAnsi to retrieve the string after the call.

Thanks, it works !

--
francois.piette@overbyte.be
http://www.o...