Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / October 2003

Tip: Looking for answers? Try searching our database.

Using (char *) in a structure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francois Piette - 02 Oct 2003 09:45 GMT
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.overbyte.be
Mattias Sj?gren - 02 Oct 2003 21:47 GMT
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

Signature

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

Francois Piette - 03 Oct 2003 09:47 GMT
> 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.overbyte.be

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.