- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to use the same code in two different applications, both delivered as a DLL called from Excel. This common code includes the same entry points which are exported in the DLL's and appear identical to Excel (normally users would only have one or other app installed).
At runtime, can I identify the DLL in use without passing the name as an argument to the DLL?
I tried GET_COMMAND_ARGUMENT, but this returns the exe name (Excel).
Thanks for any ideas,
David
At runtime, can I identify the DLL in use without passing the name as an argument to the DLL?
I tried GET_COMMAND_ARGUMENT, but this returns the exe name (Excel).
Thanks for any ideas,
David
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Windows API's that you could use are GetModuleHandleEx (using the GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS flag and passing LOC(some_proc_in_your_dll)) and GetModuleFilename.
But I think you're going to have to write your own interface to the first one - I couldn't find the bits in kernel32.f90.
A simpler alternative might be to have /fpp plus some sort of /Dsymbol=value on the compile command line, where the value is application specific and ends up in a parameter that you can test in code. This is robust to the user renaming the DLL.
ifort /fpp /DFLAVOUR_STRING='xxx'
CHARACTER(*), PARAMETER :: flavour = FLAVOUR_STRING
IF (flavour == 'xxx') CALL SpecialStuff(...)
But I think you're going to have to write your own interface to the first one - I couldn't find the bits in kernel32.f90.
A simpler alternative might be to have /fpp plus some sort of /Dsymbol=value on the compile command line, where the value is application specific and ends up in a parameter that you can test in code. This is robust to the user renaming the DLL.
ifort /fpp /DFLAVOUR_STRING='xxx'
CHARACTER(*), PARAMETER :: flavour = FLAVOUR_STRING
IF (flavour == 'xxx') CALL SpecialStuff(...)

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page