Removing dependency on PSAPI.DLL, and instead, load it when it's needed (and available) just for one EnumProcesses function.

tl;dr: This fixes Windows 95 support
This commit is contained in:
leilei-
2016-06-01 04:09:11 -04:00
parent ea9bdc0a68
commit 22d8f94415
3 changed files with 30 additions and 5 deletions

View File

@@ -603,7 +603,7 @@ ifeq ($(PLATFORM),mingw32)
TOOLS_BINEXT=.exe
endif
LIBS= -lws2_32 -lwinmm -lpsapi
LIBS= -lws2_32 -lwinmm
CLIENT_LDFLAGS += -mwindows
CLIENT_LIBS = -lgdi32 -lole32
RENDERER_LIBS = -lgdi32 -lole32 -lopengl32

View File

@@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
typedef unsigned int glIndex_t;
// Lousy hack
#define GLSL_POSTPROCESS 1
#define GLSL_POSTPROCESSING 1
#define GLSL_TEXTURES 1
#define GLSL_BACKEND 1

View File

@@ -844,8 +844,33 @@ qboolean Sys_PIDIsRunning( int pid )
DWORD numBytes, numProcesses;
int i;
if( !EnumProcesses( processes, sizeof( processes ), &numBytes ) )
return qfalse; // Assume it's not running
// leilei - load PSAPI.DLL here, check for EnumProcesses.
// Fixes Windows 95 support.
HMODULE psapi = LoadLibrary("psapi.dll");
FARPROC qEnumProcesses;
if(psapi == NULL)
{
Com_Printf("Unable to load PSAPI.dll\n");
FreeLibrary(psapi);
return qfalse;
}
qEnumProcesses = GetProcAddress(psapi, "EnumProcesses");
if(qEnumProcesses == NULL)
{
Com_Printf("Unable to find EnumProcesses in psapi.dll\n");
FreeLibrary(psapi);
return qfalse;
}
if( !qEnumProcesses( processes, sizeof( processes ), &numBytes ) ){
FreeLibrary(psapi);
return qfalse; // Assume it's not running
}
FreeLibrary(psapi); // we're still done
numProcesses = numBytes / sizeof( DWORD );
@@ -855,7 +880,7 @@ qboolean Sys_PIDIsRunning( int pid )
if( processes[ i ] == pid )
return qtrue;
}
return qfalse;
}