Página 1 de 1

como saber quais aplicativos estão aberto na barra do window

Enviado: 15 Jun 2023 15:56
por juniorcamilo
amigos...

como saber quais aplicativos estão aberto na barra do windows (harbour123)?

como saber quais aplicativos estão aberto na barra do window

Enviado: 16 Jun 2023 14:45
por sygecom
Veja se essa abaixo do colega Vailton, lhe atende:

Código: Selecionar todos

/*
* WIN_GETPROCESSLIST( aArray [, <cProcessToFind> ] ) -> nResult
* Get current process list on Windows OS. by Vailton Renato <vailtom@gmail.com>
*
* Returns:
*
* 0 - Success
* 1 - Argument error
* 2 - Unable to obtain current process list.
* 3 - Error retrieving information about processes.
*
* 15/12/2009 - 18:58:58
*/
HB_FUNC( WIN_GETPROCESSLIST )
{
 HANDLE hProcessSnap;
 PROCESSENTRY32 pe32;
 PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
 const char * szAppName = hb_parcx(2);
 BOOL bCanAdd = TRUE;

 if( !pArray )
 {
   hb_retni( 1 );
   return;
 }

 // Take a snapshot of all processes in the system.
 hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

 if( hProcessSnap == INVALID_HANDLE_VALUE )
 {
  // CreateToolhelp32Snapshot (of processes)
  hb_retni( 2 );
  return;
 }

 // 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 ) )
 {
  hb_retni( 3 );
  CloseHandle( hProcessSnap );     // clean the snapshot object
  return;
 }

 // Ignores a empty string on seconds argument
 if ( hb_parclen(2) < 1 )
   szAppName = NULL;

 // Now walk the snapshot of processes, and
 // display information about each process in turn
 do
 {
  PHB_ITEM pSubarray;

  if (szAppName)
   bCanAdd = ( hb_stricmp( szAppName, pe32.szExeFile ) == 0 );

  if (bCanAdd)
  {
   pSubarray = hb_itemNew( NULL );

   hb_arrayNew( pSubarray, 5 );
   hb_arraySetC  ( pSubarray, 1, pe32.szExeFile );          // Process Name
   hb_arraySetNInt ( pSubarray, 2, pe32.th32ProcessID );        // Process ID
   hb_arraySetNInt ( pSubarray, 3, pe32.th32ParentProcessID );     // Parent process ID

   GetUserAndDomainFromPID( pe32.th32ProcessID,
                hb_arrayGetItemPtr( pSubarray, 4 ),    // User
                hb_arrayGetItemPtr( pSubarray, 5 ) );   // Domain
   hb_arrayAddForward( pArray, pSubarray );
  }
 } while( Process32Next( hProcessSnap, &pe32 ) );

 CloseHandle( hProcessSnap );
 hb_retni( 0 );
 return;
}

como saber quais aplicativos estão aberto na barra do window

Enviado: 05 Jul 2023 14:24
por clodoaldomonteiro
Olá Leonardo, tudo em paz?

Me interessei pela rotina que vc passou, e pergunto quais serias os "Includes" C que devemos anexar à rotina acima?