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++ / December 2006

Tip: Looking for answers? Try searching our database.

Problem passing structs to dll's

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
olidem - 29 Dec 2006 10:18 GMT
Hi!

I am confused about the abnormal behaviour of my project.

Please consider the following situation:
I have written an application in C++.NET 2003 (managed) which loads and
executes an unmanaged function from an unmanaged dll.

On the dll-side i export this function:

typedef struct {
int a;
int b;...} mystruct;

__declspec(dllexport) int dllfn(mystruct* x);

Ok.
This all compiles (and also executes, I can test this via logfiles, etc).
BUT:
If I assign values to the given struct, they "do not arrive" in the main
(managed) application!!!

So, something like

x->a=17;

in the dll surprisingly does not set the value to 17 in the "real" struct
allociated in the main application. On the other hand, the same instruction
in the dll with

x->a=17; printf("a: %ld", x->a);

Works!!!

I do not have any idea, why I apparently do not have access to the struct I
want.

PLEASE HELP ME!

Thank you very much for your great help in advance!!!!

Kind regards!
olidem - 29 Dec 2006 10:32 GMT
Another question:
Do I have to export the definition of this struct explicitly, or is it
enough to just define the same struct in both the dll and the client
application?

Thanks in advance!

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.