Jump to content
  • Advertisement
Sign in to follow this  
Zipster

Getting project options at compile-time

This topic is 4927 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!