Home > Software engineering >  For specified application process
For specified application process

Time:10-02

/* 
The header file: # include "tlhelp32. H"
Function name: Exception ()
Creation date: 20170330 LuckyRen
Function description: the software platform to open the exception handling repair (the software state set as the initial state)
Parameter description: strname: software name
*/
Void CStackedWndCtrl: : SoftException (cstrings strname)
{
//check to see if the program has been running in check process way
//strname=_T (" MDW - C.e xe ");
Strname=strname + _T (". Exe ");//process the file name
BOOL bJudge=false;
DWORD procID;//this process ID
DWORD parentID.//the parent process ID
BJudge=GetProcessID (strname procID, parentID);//get the filename specified process
if(! BJudge)
{//if the corresponding software abnormal exit, the software state set as the initial state
TheApp. G_StateFlag=TRUE;
}
}
/*
The function name: GetProcessID ()
Creation date: 20170330 LuckyRen
Function description: access to the specified process
Parameter description: ProcessName: process name hProcID: this process ID ParentID: the parent process ID
*/
BOOL CStackedWndCtrl: : GetProcessID (cstrings ProcessName, dwords & amp; HProcID, dwords & amp; ParentID)
{
Int con=0;//process to find several
CString str;
PROCESSENTRY32 pe32;
Pe32. DwSize=sizeof (pe32);
//get all processes inside the system snapshot
HANDLE hProcessSnap=: : CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
If (hProcessSnap==INVALID_HANDLE_VALUE)
{
Return FALSE;
}
The first process of//enumerations
BOOL bProcess=Process32First (hProcessSnap, & amp; Pe32);
While (bProcess)
{
STR=pe32. SzExeFile;
If (STR==_T (" MDW - C.e xe "))
{//test for specified filename process
//AfxMessageBox (STR);
}
//process name, find the process of looking for name
If (ProcessName.Com pareNoCase (STR)==0)
{
Con++;//process number 1 (processes) to find the
}
//to find
BProcess=Process32Next (hProcessSnap, & amp; Pe32);
}
The CloseHandle (hProcessSnap);
If (con>
=1)return TRUE;//process has been started
The else
Return FALSE;//process didn't start
}

CodePudding user response:

It is recommended to use spy4win software,

CodePudding user response:

The code should have no problem.
Just pay attention to the rights issue, not authority, you may get less than some process.

CodePudding user response:

Using Spy++
  • Related