Jump to content

» «

[SRC|REL] C++ code to check if SA's running

No replies to this topic
[email protected]


Posted 29 January 2007 - 08:52 PM

Hey all, I've made a few little C++ functions to check if SA's process is running, this does not only do a check on its window, but it also does a check if the program "gta_sa.exe" is running, by using Wbem/WMI. I don't know for which versions of Windows it works, it works for Window XP, I think it will work Windows 2000 as well, and maybe it works for Windows 98/Me, but I can't check that.

By the way, with a few modification, this can be made to work for VC and III!


How to use it:

First, call InitializeWbem to initialize all the COM-objects (this takes quite long, 1 or 2 seconds). After that, you can call getGTASAPID and findGTASAProcess as often as you want. After you're finished, call UninitializeWbem to release the COM-objects.

Here's a simple program demonstrating its usage:
#include "findsa.h"
#include <stdio.h>

int main()
 printf("Wbem succesfully initialized\n");
 printf("Wbem could not be initialized\n");

for (;;)
 HANDLE hProc = findGTASAProcess();
 printf("Result of findGTASAProcess call: %u\n", hProc);
 if(getchar() == 'x') break;


return 0;

(Press x and then Enter to quit)

You may use it freely in all of your programs, and if you'd credit me, that'd be great!

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users