• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 13 رای - 2.31 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: سورس کد بدست اوردن لیست پروسه های در حال اجرا
حالت موضوعی
#1
C++ List all running process in the system

با سورس زیر در سی پلاس پلاس میتونید لیست پروسه های سیستم رو بدست بیارید

کد:
#include "psapi.h"
void main()
{
   // Get the list of process identifiers.  
   DWORD aProcesses[1024], cbNeeded, cProcesses;
   unsigned int i;
  
   //This returns a list of handles to processes running on the system as an array.
   if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
      return;
  
   // Calculate how many process identifiers were returned.  
   cProcesses = cbNeeded / sizeof(DWORD);
  
   // Display the name and process identifier for each process.  
   for ( i = 0; i < cProcesses; i++ )
      if( aProcesses[i] != 0 )
         DisplayProcessNameAndID( aProcesses[i] );  
}
void DisplayProcessNameAndID( DWORD processID )
{
   TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
  
   // Get a handle to the process.  
   HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
      PROCESS_VM_READ,
      FALSE, processID );
  
   // Get the process name.  
   if (NULL != hProcess )
   {
      HMODULE hMod;
      DWORD cbNeeded;
    
      //Given a handle to a process, this returns all the modules running within the process.
      //The first module is the executable running the process,
      //and subsequent handles describe DLLs loaded into the process.
      if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) )
      {
         //This function returns the short name for a module,
         //typically the file name portion of the EXE or DLL
         GetModuleBaseName( hProcess, hMod, szProcessName,
            sizeof(szProcessName)/sizeof(TCHAR) );
      }
   }
  
   // Display the process name and identifier.
   CString str;
   str.Format("Text:%s, PID : %u", szProcessName, processID );
   AfxMessageBox(str);
  
   //close the process handle
   CloseHandle( hProcess );
}
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  سورس کد خواندن فایل تکست (سی پلاس پلاس) Amin_Mansouri 2 8,438 09-05-2017، 12:08 PM
آخرین ارسال: ehsan.bc12
  سورس کد ایجاد افکت های مورد نظر (سی پلاس پلاس) Amin_Mansouri 0 4,731 12-06-2012، 12:29 PM
آخرین ارسال: Amin_Mansouri
  سورس کد دانلودر(سی پلاس پلاس) Amin_Mansouri 0 6,105 09-17-2012، 07:08 PM
آخرین ارسال: Amin_Mansouri
  سورس کد Thrip Port Scanner Amin_Mansouri 0 6,510 09-13-2012، 05:04 PM
آخرین ارسال: Amin_Mansouri
  سورس های ++C Ghoghnus 6 9,286 07-12-2012، 08:46 AM
آخرین ارسال: امیر
  سورس کد اینکریپت و دیکریپت (سی) Amin_Mansouri 1 4,556 07-07-2012، 05:13 PM
آخرین ارسال: one hacker alone
  سورس کد نمایش حجم فایل مورد نظر (سی) Amin_Mansouri 0 3,673 06-16-2012، 08:32 PM
آخرین ارسال: Amin_Mansouri
  سورس کد تبدیل مگابایت به کیلوبایت (سی) Amin_Mansouri 0 5,282 06-16-2012، 08:28 PM
آخرین ارسال: Amin_Mansouri
  سورس کد خالی کردن سطل زباله سیستم عامل ( سی ) Amin_Mansouri 0 3,568 06-16-2012، 08:25 PM
آخرین ارسال: Amin_Mansouri
  سورس کد ماشین حساب (سی پلاس پلاس) Amin_Mansouri 1 5,980 06-16-2012، 08:17 PM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان