LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Obtain task list from task manager

Hi All,

 

I have a CVI Labwindow program. I call a web page using InetLaunchDefaultWebBrowser function, when a button is pressed in the UI. I need to suspend the processing of my Labwindow program until web page is closed. I have a question here. How do I get the task list from the task manager ? I want to get the task list and not process list running on the host machine as there may be other instances of web browser running.

 

Thanks,

Kanu

 

0 Kudos
Message 1 of 2
(3,047 Views)

Hi Kanu,

 

perhaps this code-snippet will help you ... 

 

regards

Peter

 

#include <tlhelp32.h> 

 

 

/// HIFN Get a list of all running processes to check if XXX is running on same system
/// HIPAR szExecutableToCheckIfRunning/char, Name of executable to look for
/// HIRET = 1 found executable to look for
/// HIRET = 0 did not found executable
/// HIRET < 0 error
int GetProcessList(char * szExecutableToCheckIfRunning) 
{
  HANDLE hProcessSnap;
  PROCESSENTRY32 pe32;
  int bFound=FALSE;
  // Take a snapshot of all processes in the system.
  hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
  if( hProcessSnap == INVALID_HANDLE_VALUE )
  {
    printf( "CreateToolhelp32Snapshot (of processes)" );
    return -1;
  }
  // Set the size of the structure before using it.
  pe32.dwSize = sizeof( PROCESSENTRY32 );
  // Retrieve information about the first process,
  // and exit if unsuccessful
  if( !Process32First( hProcessSnap, &pe32 ) )
  {
    printf( "Process32First") ; // show cause of failure
    CloseHandle( hProcessSnap );          // clean the snapshot object
    return -1;
  }
  // Now walk the snapshot of processes, and
  // display information about each process in turn
  do
  {
    if (stricmp(pe32.szExeFile, szExecutableToCheckIfRunning)==0)
      bFound=TRUE;
  } while( Process32Next( hProcessSnap, &pe32 ) );
  CloseHandle( hProcessSnap );
  return bFound;
}

 

0 Kudos
Message 2 of 2
(3,039 Views)