D2 Win API Problem
A Bothe
info at alexanderbothe.com
Sun Sep 20 11:11:52 PDT 2009
Hello guys,
I got a problem with the following code. I can compile it successfully but when I want to start it, there is just this "object.AccessVialotion"!
Even GetLastError() returns 0.... so the problem cannot be found in wrong-written names...
Thanks in advance!
import std.loader, std.c.windows.windows;
int function(HWND hwnd,char* text,char* title, uint style) tfunc=null;
class Module
{
private HXModule hm;
public HXModule Handle() {return hm;}
this(string name)
{
hm=ExeModule_Load(name);
}
Fun GetSymbol(Fun)(ref Fun func,string name)
{
return func=cast(Fun)ExeModule_GetSymbol(hm,name);
}
}
void main(){
Module m=new Module("user32.dll");
m.GetSymbol(tfunc,"MessageBoxA");
tfunc(null,cast(char*)"Test",cast(char*)"TestTitle",MB_OK);
}
-------
Check out my D-IDE on http://www.alexanderbothe.com/?id=27
More information about the Digitalmars-d-learn
mailing list