BOOL FindProcess ()
{
int i=0;
PROCESSENTRY32 pe32;
Pe32. DwSize=sizeof (pe32);
HANDLE hProcessSnap=: : CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
If (hProcessSnap==INVALID_HANDLE_VALUE)
{
I +=0;
}
BOOL bMore=: : Process32First (hProcessSnap, & amp; Pe32);
While (bMore)
{
Process name://printf (" % s \ n ", pe32. SzExeFile);
If (stricmp (" TExt ", pe32 szExeFile)==0)
{
//printf (" in the operation of the process ");
I +=1;
}
BMore=: : Process32Next (hProcessSnap, & amp; Pe32);
}
If (I & gt; 1) {//is greater than 1, eliminate their own
return true;
}
The else {
return false;
}
}
Source is such, but in pe32 szExeFile this position has been prompt me: WCHAR * "type of real participation" const char * "type of parameter is incompatible;
Want to be consulted in do not change the situation of the character set how to solve this problem?
CodePudding user response:
# include & lt; Atlconv. H>
using namespace std;
BOOL FindProcess ()
{
int i=0;
PROCESSENTRY32 pe32;
Pe32. DwSize=sizeof (pe32);
HANDLE hProcessSnap=: : CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
If (hProcessSnap==INVALID_HANDLE_VALUE)
{
I +=0;
}
BOOL bMore=: : Process32First (hProcessSnap, & amp; Pe32);
While (bMore)
{
USES_CONVERSION;
Process name://printf (" % s \ n ", pe32. SzExeFile);
If (_stricmp (" TExt ", W2A (pe32. SzExeFile))==0)
{
//printf (" in the operation of the process ");
I +=1;
}
BMore=: : Process32Next (hProcessSnap, & amp; Pe32);
}
If (I & gt; 1) {//is greater than 1, eliminate their own
return true;
}
The else {
return false;
}
}
CodePudding user response:
_tcsicmp (TEXT (" TEXT "), pe32. SzExeFile)