Sign in to follow this  

Getting project options at compile-time

This topic is 4715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there any way to get the name of the module file being output by the linker at compile-time? I know from within .NET you have access to all these facilities where you can access project options from code, but does the same thing exist in vanilla C++ (MSVC 7.1 in particular)? The reason I have to do this is so I can pass it to GetModuleHandle from within a DLL, and if I don't pass the filename then it returns the parent EXE handle. I'd like to avoid hard-coding it if possible and allow it to automatically detect it from the project settings. The output file can also change based on whether it's a debug or release build, so not having to put in those ugly #define's would make things better as well.

Share this post


Link to post
Share on other sites
Just hard-code the module name. If your module is named FOO.DLL, just use: GetModuleHandle("FOO.DLL");

If you need to differentiate between debug and release:


#ifndef _DEBUG
#define MODULE_NAME "FOO_D.DLL"
#else
#define MODULE_NAME "FOO.DLL"
#endif

// in the code
HMODULE mod = GetModuleHandle(MODULE_NAME);

Share this post


Link to post
Share on other sites

This topic is 4715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this