A DLL to modify a variable?
Gilles G.
schaouette at free.fr
Tue Jun 26 03:29:10 PDT 2007
Hello,
maybe I am obviously missing something, but it seems that my dll doesn't modify the value of the variables.
It looks like this:
=== File from the DLL (with the corresponding def file)
extern(Windows) void modifyThis(int* val){*val=0;}
=== call to the DLL function in the test program
alias void function(int*) modifyThis_t;
modifyThis_t modifyThis;
HMODULE h;
h = LoadLibraryA("test.dll");
int value=1;
modifyThis = cast(modifyThis_t) GetProcAddress(h,"modifyThis");
writefln("Value before call: %d",value);
(*modifyThis)(&value);
writefln("Value after call: %d",value);
But then I get the output:
Value before call: 1
Value after call: 1
I guess this is a beginner's question...
Thanks a lot!
More information about the Digitalmars-d-learn
mailing list