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 / Languages / Managed C++ / May 2007

Tip: Looking for answers? Try searching our database.

Getting Unmanaged struct data to C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jcteague@gmail.com - 27 Apr 2007 17:21 GMT
What is the best way to get a set of unmanaged structs to C#.

I have the following structs:
typedef struct
{
unsigned char Angle[4];
unsigned char Rayon[3];
} StructPointPolaire;
//---------------------------------------------------------------------------
typedef struct
{
StructPointPolaire PointPolaire[36];
}StructForme36Points;
...
typedef struct
{
StructForme36Points        Forme36Points;
...//more structs with similar data
char FinFichier[3];
} StructFormatMo1;

StructFormatMo1 is inside an unmanaged c++ class for which I have a
managed wrapper.  The structs are filed in the constructor.

I need to access StructFormatMo1 (and the structs inside of course) in
C#.  I won't be modifying the data and sending back to the c++
objects.

Thank you very much,
John
Ben Voigt - 07 May 2007 15:56 GMT
> What is the best way to get a set of unmanaged structs to C#.
>
[quoted text clipped - 5 lines]
> } StructPointPolaire;
> //---------------------------------------------------------------------------

Use an unsafe C# struct with the fixed keyword.

C++ unsigned char corresponds to C# byte.

> typedef struct
> {
[quoted text clipped - 17 lines]
> Thank you very much,
> John

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.