Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HANDLE GetProcessHandle( char* szProcessName )
- {
- PROCESSENTRY32 Entrada;
- HANDLE Final, SnapShot;
- Entrada.dwSize = sizeof(PROCESSENTRY32);
- SnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
- Process32First( SnapShot, &Entrada );
- if( !strcmp( szProcessName, Entrada.szExeFile ) )
- goto pegapid;
- while(Process32Next( SnapShot, &Entrada ))
- {
- if(!strcmp( szProcessName, Entrada.szExeFile ))
- {
- goto pegapid;
- }
- }
- goto final;
- pegapid:
- Final = OpenProcess( PROCESS_ALL_ACCESS, false, Entrada.th32ProcessID );
- printf( "Process found !\n" );
- return Final;
- final:
- printf( "Process not found !\n" );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement