Q:

When using C++ Builder, is there a string in the exe that indicates whether a file was built in Debug mode

I am using Embarcaredo's C++ Builder XE3.
Is there any information in the exe file, preferably a string that I can search for, that shows whether the file was generated in Debug mode or Release mode?
Also, is there any way I can detect Debug mode when I compile. In other words, is there a way I can do something like this, where the IDE is defining DEBUG_MODE for me automatically.
#if defined ( DEBUG_MODE )
// some extra code
#endif

A:

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;
}

