Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


c++ check process if running or no

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
mr.moon
Newbie cheater
Reputation: 0

Joined: 27 Aug 2016
Posts: 12

PostPosted: Sat Aug 27, 2016 11:07 pm    Post subject: c++ check process if running or no Reply with quote

Hello Everone ^^
i have a little problem
first the code is here
Code:
int main()
{
   DWORD processId = NULL;
   PROCESSENTRY32 pe32 = {sizeof(PROCESSENTRY32)};
   HANDLE hProcSnap;
   while(!processId)
   {
      cout << "Searching for " << ProcessName <<"..." <<endl;
      hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
      if(Process32First(hProcSnap, &pe32))
      {
         do
         {
         if(!strcmp(pe32.szExeFile, ProcessName))
            {
               processId = pe32.th32ProcessID;
               break;
            }
         }
         while(Process32Next(hProcSnap, &pe32));
      }
   }
   cout << "Found Process!" << endl << endl;
   CloseHandle(hProcSnap);
   return 0;
}

using console application the problem is i am set propety on Unicode and that cause a problem in this line if(!strcmp(pe32.szExeFile, ProcessName))
error there (pe32.szExeFile)
error info
    Error (active) argument of type "WCHAR *" is incompatible with parameter of type "const char *"
    Error C2664 'int strcmp(const char *,const char *)': cannot convert argument 1 from 'WCHAR [260]' to 'const char *'

to fix it need to change Property to Multi-Byte but can't do
that because others functions depend on Unicode so is there other way or fix for that to check the process is running or no ?!
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Aug 27, 2016 11:23 pm    Post subject: Reply with quote

Use the unicode version of strcmp. 'wcscmp'

Or use the TCHAR variants so things will compile in both unicode and multibyte. '_tcscmp'

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
mr.moon
Newbie cheater
Reputation: 0

Joined: 27 Aug 2016
Posts: 12

PostPosted: Sun Aug 28, 2016 5:53 am    Post subject: Reply with quote

[quote="atom0s"]Use the unicode version of strcmp. 'wcscmp'

got it thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites