Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Core/Tools/MapCacheBuilder/Source/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,15 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,

// Set the current directory to the app directory.
char buf[_MAX_PATH];
GetModuleFileName(NULL, buf, sizeof(buf));
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
buf[0] = '\0'; // Initialize buffer to empty string
DWORD result = GetModuleFileName(NULL, buf, sizeof(buf));
if (result > 0 && result < sizeof(buf))
{
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
::SetCurrentDirectory(buf);
}
}
::SetCurrentDirectory(buf);

/*
** Convert WinMain arguments to simple main argc and argv
Expand Down
12 changes: 8 additions & 4 deletions Generals/Code/Main/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,12 +795,16 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,

/// @todo remove this force set of working directory later
Char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
if (Char *pEnd = strrchr(buffer, '\\'))
buffer[0] = '\0'; // Initialize buffer to empty string
DWORD result = GetModuleFileName( NULL, buffer, sizeof( buffer ) );
if (result > 0 && result < sizeof(buffer))
{
*pEnd = 0;
if (Char *pEnd = strrchr(buffer, '\\'))
{
*pEnd = 0;
::SetCurrentDirectory(buffer);
}
}
::SetCurrentDirectory(buffer);


#ifdef RTS_DEBUG
Expand Down
12 changes: 8 additions & 4 deletions Generals/Code/Tools/GUIEdit/Source/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,16 @@ Int APIENTRY WinMain(HINSTANCE hInstance,

/// @todo remove this force set of working directory later
Char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
if (Char *pEnd = strrchr(buffer, '\\'))
buffer[0] = '\0'; // Initialize buffer to empty string
DWORD result = GetModuleFileName( NULL, buffer, sizeof( buffer ) );
if (result > 0 && result < sizeof(buffer))
{
*pEnd = 0;
if (Char *pEnd = strrchr(buffer, '\\'))
{
*pEnd = 0;
::SetCurrentDirectory(buffer);
}
}
::SetCurrentDirectory(buffer);

// initialize the memory manager early
initMemoryManager();
Expand Down
12 changes: 8 additions & 4 deletions GeneralsMD/Code/Main/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,12 +856,16 @@ Int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

/// @todo remove this force set of working directory later
Char buffer[_MAX_PATH];
GetModuleFileName(NULL, buffer, sizeof(buffer));
if (Char* pEnd = strrchr(buffer, '\\'))
buffer[0] = '\0'; // Initialize buffer to empty string
DWORD result = GetModuleFileName(NULL, buffer, sizeof(buffer));
if (result > 0 && result < sizeof(buffer))
{
*pEnd = 0;
if (Char* pEnd = strrchr(buffer, '\\'))
{
*pEnd = 0;
::SetCurrentDirectory(buffer);
}
}
::SetCurrentDirectory(buffer);


#ifdef RTS_DEBUG
Expand Down
12 changes: 8 additions & 4 deletions GeneralsMD/Code/Tools/GUIEdit/Source/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,16 @@ Int APIENTRY WinMain(HINSTANCE hInstance,

/// @todo remove this force set of working directory later
Char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
if (Char *pEnd = strrchr(buffer, '\\'))
buffer[0] = '\0'; // Initialize buffer to empty string
DWORD result = GetModuleFileName( NULL, buffer, sizeof( buffer ) );
if (result > 0 && result < sizeof(buffer))
{
*pEnd = 0;
if (Char *pEnd = strrchr(buffer, '\\'))
{
*pEnd = 0;
::SetCurrentDirectory(buffer);
}
}
::SetCurrentDirectory(buffer);

// initialize the memory manager early
initMemoryManager();
Expand Down
Loading