C++ statische Statusanzeige

Hi,

ich möchte gerne mit meinem Programm eine andere Anwendung suchen und den Status anzeigen lassen ( also läuft oder eben nicht ).
Das Fenster finde ich, nur bei der Status Anzeige haperts.
Das habe ich bis jetzt in meiner Nachrichtenschleife bzw. in meiner Callback Funktion (ich arbeite dialog basierend also mit einer Resourcedatei):

Code:
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {
        case WM_INITDIALOG:

            return TRUE;

        case WM_CLOSE:
            CloseHandle (winHandle);
            EndDialog(hwndDlg, 0);
            return TRUE;

        case WM_COMMAND:
            switch(LOWORD(wParam))
            {

            }
    }
      procid = GetProcessId ("notepad.exe");
      winHandle = OpenProcess ( PROCESS_ALL_ACCESS, false, procid );

   

        if ( winHandle && !found )
        {
            SetDlgItemText ( hwndDlg , IDC_STC1 , isRunning );
            HWND SetActiveWindow ( hwndDlg );
            found = true;
        }
        else if ( !winHandle && found )
        {
            SetDlgItemText ( hwndDlg , IDC_STC1 , isNotRunning );
            HWND SetActiveWindow ( hwndDlg );
            found = false;
        }

   return FALSE;
}

Wenn die gesuchte Anwendung nicht da ist kriege ich meine Statusanzeige aber sobald die Anwendung da ist schwankt der Status (statischer Text) ganz schnell hin und her so als ob beide Bedingungen abwechselnd TRUE sind o0
 
Wie schaut denn deine Überladung von GetProcessId aus?

EDIT:
So geht es bei mir:
Code:
#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
#include <shlwapi.h>

unsigned long GetTargetProcessIdFromProcname(char *procName)
{
   PROCESSENTRY32 pe;
   HANDLE thSnapshot;
   BOOL retval, ProcFound = false;

   thSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

   if(thSnapshot == INVALID_HANDLE_VALUE)
   {
      MessageBox(NULL, "Error: unable to create toolhelp snapshot", "Loader", MB_OK);
      return false;
   }

   pe.dwSize = sizeof(PROCESSENTRY32);

   retval = Process32First(thSnapshot, &pe);

   while(retval)
   {
      if(StrStrI(pe.szExeFile, procName) )
      {
         ProcFound = true;
         break;
      }

      retval    = Process32Next(thSnapshot,&pe);
      pe.dwSize = sizeof(PROCESSENTRY32);
   }
   
   if(pe.th32ProcessID == GetCurrentProcessId())
          return false;
   
   return pe.th32ProcessID;
}

int main() {
    DWORD procid = GetTargetProcessIdFromProcname("notepad.exe");
    
    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, procid);
    
    if(hProc)
             printf("notepad.exe running!");
    else
             printf("notepad.exe not found!");
             
    
    CloseHandle(hProc);
    
    getchar();
    return 0;   
}
 
Zurück
Oben