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 / Interop / October 2004

Tip: Looking for answers? Try searching our database.

Marshal **

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kat - 14 Oct 2004 19:45 GMT
Hi,

I am trying to call an unmanaged dll from a C# class.  In the dll, I had a
structure that looks like this:

typedef struct subbuffer{
   int format;
}

Then I have another structure that looks like:

typedef struct bufferStruct{
   int count;
   subbuffer** newBuffer;
}

The function to my unmanaged dll calls a pointer to the buffer structure
like this:

void acquireInfo(bufferStruct* finalBuffer)

I have been able to see the count correctly, and I get an address for the
subbuffer.  I just can't get the format value from the subbuffer.

How do I declare that second structure in C#?

Any help would be appreciated.  Thanks!
Mattias Sj?gren - 16 Oct 2004 20:19 GMT
>How do I declare that second structure in C#?

You could do it like this

struct bufferStruct{
   public int count;
   public IntPtr newBuffer;
}

Then use Marshal.ReadIntPtr to dereference to one or more subbuffer*,
and finally Marhal.ReadInt32 to read the format value if subbuffer
really only consists of a single int.

Mattias

Signature

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

kat - 18 Oct 2004 14:45 GMT
Thanks for the response, Mattias.  

The actual problem that I am having is not reading it in my C# code.  The
function is called in the C library.  When I am debuggin, the only value that
isn't showing up properly in the function call is that integer.  I can see
the integer value in the C# code, but when it gets to the library the value I
see is an 8 digit number that is never the value I set.  How do I get it so
that I can see the correct value in the C code?

Thanks,

kat

"Mattias Sjögren" wrote:

> >How do I declare that second structure in C#?
>
[quoted text clipped - 10 lines]
>
> Mattias

Rate this thread:







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.