Re: Where is my DLL?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Wolf wrote:

>> how can a DLL find the path where it was loaded from?
>> Somewhere on the internet I read:
>>| If you want to find the path for a DLL, pass the DLLs instance handle,
>>| which you can obtain from the first parameter in your DLL's DLLMain()
>>| function.
>>
>> Of course in Euphoria there is no DLLMain() function.
>
> When you create your DLL using "DLL_PROCESS_ATTACH", etc, this is! your
> DLLMain() function, though some call it LibMain(), or whatever...

I don't know what DLL_PROCESS_ATTACH is. (And the problem here is, that
I don't know much about C at all.)
However, I've seen now that Eu code translated for Borland has a function
    DllMain()
and Eu code translated for Watcom has a function
    LibMain().

> ...and the function's first parameter can be used to call
> GetModuleFileName(), I'd guess.

Yes. Now I've found a (hopefully correct) way to fetch the value of that
parameter, so that I can use it in my Eu DLL.
I wrote the following small include file:

--------------------------[ dll_instance.e ]--------------------------
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

----------------------------------------------------------------------

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.

Wolf, do you know a better way to get the value of the first parameter
of DllMain()/LibMain()? blink

<snip>

Thanks,
   Juergen

-- 
Have you read a good program lately?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu