Re: Where is my DLL?
- Posted by "Juergen Luethje" <j.lue at gmx.de> Oct 19, 2005
- 564 views
Robert Craig wrote: > Juergen Luethje wrote: >> >> Me wrote: >> >> [How can a DLL written in Euphoria get its own instance handle?] >> >> <snip> >> >>> Now I've found a (hopefully correct) way to fetch the value of >>> [the first parameter of DllMain()/LibMain()] so that I can use >>> it in my Eu DLL. >>> I wrote the following small include file: >>> >>> --------------------------[ dll_instance.e ]-------------------------- >>> }}} <eucode> >>> atom DLL_Instance >>> -- DLL_Instance = 0 -- Initialize the variable only when >>> -- testing the program with the >>> -- interpreter, *not* when compiling >>> -- to a DLL! >>> global function dll_instance() >>> return DLL_Instance >>> end function >>> </eucode> {{{ >>> ---------------------------------------------------------------------- >>> >>> I include this file in the code of my DLL, and after translation, >>> in the file "main_.c" I add something like >>> >>> _2DLL_Instance = hDLL; >>> >>> as the first line to either DllMain() or LibMain(). >>> When dll_instance.e is not the 1st but the 2nd included file, then >>> the number must be not 2, but 3 etc. A small Eu program does it for me. >>> >>> This seems to work fine so far. Unfortunately, I always have to >>> uncomment the line in the include file that initializes the variable >>> 'DLL_Instance', before I can run the code with the interpreter. >> >> <snip> >> >> Rob, I just thought that I'd sleep better if you could confirm that I'm >> not doing something potentially dangerous here. > > I'm not sure. If hDLL is greater than a 31-bit integer > there will be trouble, since Euphoria requires it to be > stored in floating-point form. You might need to call > my C routine NewDouble() to create a proper Euphoria atom > in floating-point form. I see, thanks. Unfortunately, I don't know how to do so. Matt, can I use make_atom() in this situation, or is it "only" for parameters? Regards, Juergen -- Have you read a good program lately?