How to return the address of a struct in a C dll
-
Hi guys,
i am writing a C dll.
In the DLL there a struct defined and will be used in a funtion PP_Ini().My question is how can i return the address of the struct used in the PP_Ini() to the Application which consums this DLL
Thanks
bag
-
since windoze .exe and dlls live in the same, virtual address space you can retunr that struct as usual...
// dll.c struct blah; .. struct blah *dll_function (void) { ... return &blah; }
// main.c ... void main (void) { struct blah *b = dll_function(); // get a pointer b->... = ...; // access the struct }
^^see the m$ online docs how to export functions from dlls, ect.
-
~fricky schrieb:
// dll.c struct blah; .. struct blah *dll_function (void) { ... return &blah; }
edit:
// dll.c struct blah blah;
-
Hi ~fricky,
thanks for your quick reply.
It really helps.Another question. Do u know c#. How the dll.c looks like in a dll.cs file?
I mean implement the DLL in C#also wanna get the struct address.
Thanks!!
bag
[quote="~fricky"]
~fricky schrieb:
// dll.c struct blah blah;
-
tttbag schrieb:
Another question. Do u know c#. How the dll.c looks like in a dll.cs file?
I mean implement the DLL in C#sorry, i know cs very little. but i know that c# is some kind of 'Java with pointers', so there's probably a good chance to do it 'the C way'.
better ask in the C# section.
-
~fricky schrieb:
but i know that c# is some kind of 'Java with pointers'
LOL!
Awesome explanation!
-
was denn? das ist doch auch so.