Check whether a program is running in PPC

Source: Internet
Author: User
Sometimes you often need to check whether a program is running. In windows mobile 5.0 system development, I often use the following methods:

First:
HANDLE hMutex =: CreateMutexW (NULL, true, L "program name ");
DWORD dwError = GetLastError ();
If (dwError = ERROR_ALREADY_EXISTS)
{
: AfxMessageBox (L "The program is running! ");
Return;
}
: ReleaseMutex (hMutex );

Second:
HWND hWmp =: FindWindowW (L "Dialog", L "program window name ");
If (hWmp)
{
: AfxMessageBox (L "The program is running! ");
Return FALSE;
}

Third:
PROCESSENTRY32 lppe;
Memset (& lppe, 0, sizeof (PROCESSENTRY32 ));
HANDLE handle = createconlhelp32snapshot (TH32CS_SNAPALL, 0 );
Lppe. dwSize = sizeof (PROCESSENTRY32 );
: Process32First (handle, & lppe );
Do
{
HANDLE hh =: OpenProcess (PROCESS_ALL_ACCESS, FALSE, lppe. th32ProcessID );
CString temp (lppe. szExeFile );
If (temp. Find (L "program name")> = 0)
{
: AfxMessageBox (L "The program is running! ");
: TerminateProcess (hh, 0 xffffffff );
: CloseHandle (hh );
Break;
}
: CloseHandle (handle );

} While (Process32Next (handle, & lppe ));
: CloseHandle (handle );

The above three methods can only check other programs, but cannot check whether they are running, because the operating mechanism of windows mobile system is not the same as that of windows XP on PC.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.