Linking against a Win32-DLL

Marc Müller dont at spam.me
Sun Jul 8 18:53:30 PDT 2007


> Guess you mean :
> implib /s wintab32.lib wintab32.DLL
> 
> Hi Marc , what tool do you use to convert the c header ? Walter s htod, 
> or Gregor s BCDGen
> Bjoern

Wow - I did not even tried to hope that I get help that fast...
Thank you a lot - the library generated by the implib tool did it!

I converted the header with htod (and quite a lot of manual work...).
I did not know BCDGen, but I'm going to check it out next time.

Nevertheless I still have a problem with the code:
Sometimes I get an "Access Violation" error out of nowhere...

For example the following Code works, the DLL-function is called 
correctly and returns with the expected Value:


void main(char[][] args)
{
	writefln("Getting WTInfo...");
	int value = WTInfo( 0, 0, null);
	writefln("Received WTInfo");
}
Output:
Getting WTInfo...
Received WTInfo


Everything is fine - but now the same code (I'm just ignoring the return 
value of the function):


void main(char[][] args)
{
	writefln("Getting WTInfo...");
	WTInfo( 0, 0, null);
	writefln("Received WTInfo");
}

This time the program fails with the following output:
Getting WTInfo...
Received WTInfo
Error: Access Violation


When I surround the 3 lines with a try-catch block it runs without even 
throwing an exception. Very strange...

I don't know how reliable the order of the program output is, but since 
the error occurs after the function call - I guess somehow I have a 
memory - or stack problem... Perhaps the calling convention? Hmm...

I just can't find out what's wrong :-(

Do you have a idea?


Hopefully,
	-Marc-



More information about the Digitalmars-d mailing list