At compile time the predefined macro are:
- in debug mode: _DEBUG
- in release mode: NDEBUG
At runtime you could use something like this (code may need some adjustments...):
bool debugBuild()
{
bool dbg(false);
// ParamStr(0) holds the complete path to the application
char *thisFile(AnsiString(ParamStr(0)).c_str());
// How big the VersionInfo buffer needs to be
DWORD unused;
DWORD verSize = GetFileVersionInfoSize(thisFile, &unused);
try
{
TCHAR *verInfoBuffer = new TCHAR[verSize + 1];
// Get the sort-of handle we'll use in further VerQueryValue call
GetFileVersionInfo(thisFile, 0, verSize, verInfoBuffer);
// Special case. If you pass in \, you get this useful
// structure passed back.
unsigned len;
::VS_FIXEDFILEINFO *ffi;
VerQueryValue(verInfoBuffer, "\\", &(void*)ffi, &len);
dbg = ffi->dwFileFlags & VS_FF_DEBUG;
}
__finally
{
delete [] p;
}
return dbg;
}