C++ Process32Next函数代码示例

本文整理汇总了C++中Process32Next函数的典型用法代码示例。如果您正苦于以下问题:C++ Process32Next函数的具体用法?C++ Process32Next怎么用?C++ Process32Next使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


C++ Process32Next函数代码示例

在下文中一共展示了Process32Next函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shutdownCcd

int shutdownCcd()
{
    PROCESSENTRY32 entry;
    entry.dwSize = sizeof(PROCESSENTRY32);
    std::wstring ccdName = L"ccd.exe";

    HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    if (Process32First(snapshot, &entry) == TRUE) {
        while (Process32Next(snapshot, &entry) == TRUE) {
            if (_wcsicmp(entry.szExeFile, ccdName.c_str()) == 0) {  
                HANDLE hHandle;
                DWORD dwExitCode = 0;
                hHandle = ::OpenProcess(PROCESS_ALL_ACCESS, 0, entry.th32ProcessID);
                      
                ::GetExitCodeProcess(hHandle,&dwExitCode);
                ::TerminateProcess(hHandle,dwExitCode);
            }
        }
    }
    CloseHandle(snapshot);
    return 0;
}
开发者ID:mbin,项目名称:acer_cloud_wifi_copy,代码行数:22,代码来源:ccd_utils_win.cpp

示例2: GetProcessPath

CString GetProcessPath(CString strImageName)
{
	PROCESSENTRY32 processInfo;
	processInfo.dwSize = sizeof(processInfo);
	HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
	DWORD dwPID = -1;
	CString strProcessName;
	if (processesSnapshot != INVALID_HANDLE_VALUE)
	{
		Process32First(processesSnapshot, &processInfo);
		strProcessName = processInfo.szExeFile;
		if (!_tcscmp(strProcessName, strImageName))
			dwPID = processInfo.th32ProcessID;
		while (dwPID == -1 && Process32Next(processesSnapshot, &processInfo))
		{
			strProcessName = processInfo.szExeFile;
			if (!_tcscmp(strProcessName, strImageName))
				dwPID = processInfo.th32ProcessID;
		}
		CloseHandle(processesSnapshot);
	}

	if (dwPID != -1)
	{
		TCHAR szModulePath[MAX_PATH] = {0};
		HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwPID);
		if (NULL != hProcess)
		{
			DWORD cbNeeded;
			HMODULE hMod;
			if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
				GetModuleFileNameEx(hProcess, hMod, szModulePath, MAX_PATH);
			CloseHandle( hProcess );
		}
		return szModulePath;
	}
	else
		return _T("");
}
开发者ID:srcdst,项目名称:work_snippet,代码行数:39,代码来源:processutil.cpp

示例3: printExplorerPid

void printExplorerPid()
{
	PROCESSENTRY32 entry;
	entry.dwSize = sizeof(PROCESSENTRY32);

	HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);

	if (Process32First(snapshot, &entry) == TRUE)
	{
		while (Process32Next(snapshot, &entry) == TRUE)
		{
			std::wstring binaryPath = entry.szExeFile;
			if (binaryPath.find(L"explorer.exe") != std::wstring::npos)
			{
				printf("Explorer's pid is %d\n", entry.th32ProcessID);
				break;
			}
		}
	}

	CloseHandle(snapshot);
}
开发者ID:buildingwatsize,项目名称:GameHackingExamples,代码行数:22,代码来源:main-accessingMemory.cpp

示例4: ListProcess

bool ListProcess()
{
    HANDLE hProcessSnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL);   //获取进程快照
    if(hProcessSnapshot==INVALID_HANDLE_VALUE)
    {
        printf("创建进程快照失败!\n");
        return false;
    }
    Privilege();    //提升令牌权限
    PROCESSENTRY32 pe32;    //用来存放快照进程信息的结构体
    /*
        typedef struct tagPROCESSENTRY32
        {
            DWORD dwSize;
            DWORD cntUsage;
            DWORD th32ProcessID;
            ULONG_PTR th32DefaultHeapID;
            DWORD th32ModuleID;
            DWORD cntThreads;
            DWORD th32ParentProcessID;
            LONG pcPriClassBase;
            DWORD dwFlags;
            TCHAR szExeFile[MAX_PATH];
        } PROCESSENTRY32, *PPROCESSENTRY32;
    */
    pe32.dwSize=sizeof(PROCESSENTRY32);   //存放结构体大小
    if(!Process32First(hProcessSnapshot,&pe32))
    {
        printf("列举第一个进程失败。\n");
        return false;
    }
    do
    {
        printf("FileName:%s\t\t\tPID:%d\n",pe32.szExeFile,pe32.th32ProcessID);
    }
    while(Process32Next(hProcessSnapshot,&pe32));

    return true;
}
开发者ID:weizn11,项目名称:C,代码行数:39,代码来源:main.cpp

示例5: CreateToolhelp32Snapshot

BOOL CVc6ConfigerApp::CheckProcessExist(CString strName, DWORD *pPID)
{
	BOOL bExist = FALSE;
	HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
	PROCESSENTRY32 info = {0};
	info.dwSize = sizeof(PROCESSENTRY32);
	BOOL bRet = Process32First(handle, &info);
	if( bRet ){
		do {
			if ( strName.Compare(info.szExeFile) == 0 ){
				if (pPID != NULL){
					*pPID = info.th32ProcessID;
				}
				bExist = TRUE;
				break;
			}
			bRet = Process32Next(handle, &info);
		} while( bRet );
		CloseHandle(handle);
	}
	return bExist;
}
开发者ID:Cay0621,项目名称:Cpp,代码行数:22,代码来源:Vc6Configer.cpp

示例6: GetSQLProcess

unsigned int GetSQLProcess()
{
    PROCESSENTRY32   pe32;
    HANDLE         hSnapshot = NULL;

    pe32.dwSize = sizeof( PROCESSENTRY32 );
    hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

    if( Process32First( hSnapshot, &pe32 ) )
    {
        do {
            if( strcmp( pe32.szExeFile, "sqlservr.exe" ) == 0 )
                break;
        } while( Process32Next( hSnapshot, &pe32 ) );
    }

    if( hSnapshot != INVALID_HANDLE_VALUE )
        CloseHandle( hSnapshot );

    return pe32.th32ProcessID;

}
开发者ID:bergercookie,项目名称:hacking,代码行数:22,代码来源:vdmallowed.c

示例7: UpdateListBoxProcess

void UpdateListBoxProcess()
{
	SendMessage(ListBoxProcess, LB_RESETCONTENT, 0, 0);

	HANDLE processSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	PROCESSENTRY32 processInfo;
	processInfo.dwSize = sizeof(PROCESSENTRY32);
	Process32First(processSnapshot, &processInfo);
	do
	{
		HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processInfo.th32ProcessID);
		DWORD priorityClass = GetPriorityClass(process);

		TCHAR listBoxLine[1024];
		swprintf((wchar_t*)listBoxLine, L"%s\t%s", processInfo.szExeFile, 
			(LPARAM)ProcessPriorityClassToString(priorityClass));
		int id = SendMessage(ListBoxProcess, LB_ADDSTRING, 0, (LPARAM)listBoxLine);
		SendMessage(ListBoxProcess, LB_SETITEMDATA, id, (LPARAM)processInfo.th32ProcessID);
		CloseHandle(process);
	} while(Process32Next(processSnapshot, &processInfo));
	CloseHandle(processSnapshot);
}
开发者ID:Raumo0,项目名称:Labs,代码行数:22,代码来源:lab_5.cpp

示例8: Find3DCoat

Bool Find3DCoat()
{
	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	PROCESSENTRY32 pe;
	if(!hSnapshot)return false;	
	pe.dwSize = sizeof(pe);
	for(int i = Process32First(hSnapshot, &pe); i; i = Process32Next(hSnapshot, &pe))
	{
		HANDLE hModuleSnap = NULL;
		MODULEENTRY32 me;
		hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pe.th32ProcessID);
		if(hModuleSnap == (HANDLE) -1)continue;
		me.dwSize = sizeof(MODULEENTRY32);
		if(Module32First(hModuleSnap, &me))
		{
			do
			{
				char temp[MAX_PATH];
				strcpy_s(temp,MAX_PATH, me.szExePath);
				_strupr_s(temp, MAX_PATH);
				int p = (int)strlen(temp);
				char c = 0;
				while(c != '\\' && c != '/' && p != 0)
				{
					c = temp[p--];
				}
				char* s = temp + p;
				strupr(s);
				if(strstr(s,"3D-COAT"))
				{
					return true;
				}
				break;
			}while(Module32Next(hModuleSnap, &me));
		}
	}
	CloseHandle(hSnapshot);
	return false;
}
开发者ID:oyaGG,项目名称:3DCoat_Applinks,代码行数:39,代码来源:ApplinkDialog.cpp

示例9: GetProcessIdByName

/*************************************
* BOOL GetProcessIdByName(LPSTR szProcessName, LPDWORD lpPID)
* 功能	通过进程名获取进程PID
*
* 参数	LPSTR szProcessName	进程名
*		LPDWORD lpPID		指向保存PID的变量
* 返回是否成功
**************************************/
BOOL GetProcessIdByName(LPSTR szProcessName, LPDWORD lpPID)
{
	// 变量及初始化
	STARTUPINFO st;
	PROCESS_INFORMATION pi;
	PROCESSENTRY32 ps;
	HANDLE hSnapshot;
	ZeroMemory(&st, sizeof(STARTUPINFO));
	ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
	st.cb = sizeof(STARTUPINFO);
	ZeroMemory(&ps,sizeof(PROCESSENTRY32));
	ps.dwSize = sizeof(PROCESSENTRY32);
	// 遍历进程
	hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0);
	if(hSnapshot == INVALID_HANDLE_VALUE)
	{
		return FALSE;
	}

	if(!Process32First(hSnapshot,&ps))
	{
		return FALSE;
	}
	do
	{
		// 比较进程名
		if(lstrcmpi(ps.szExeFile,"explorer.exe")==0)
		{
			// 找到了
			*lpPID = ps.th32ProcessID;
			CloseHandle(hSnapshot);
			return TRUE;
		}
	}
	while(Process32Next(hSnapshot,&ps));
	// 没有找到
	CloseHandle(hSnapshot);
	return FALSE;
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:47,代码来源:remote.c

示例10: GetProcessHandle

BOOL GetProcessHandle(PHANDLE lpTokenHandle, char *lpszProcName)
{
	if (NULL == lpszProcName)
		return NULL;
	
	PROCESSENTRY32 pe = {};
	
	__tfnCreateToolhelp32Snapshot lpfnCreateToolhelp32Snapshot = (__tfnCreateToolhelp32Snapshot)GetProcAddress(
		LoadLibrary("kernel32.dll"),
		"CreateToolhelp32Snapshot"
	);
	HANDLE hSnapshot = lpfnCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	
	if (INVALID_HANDLE_VALUE == hSnapshot)
		return NULL;
	
	pe.dwSize = sizeof(PROCESSENTRY32);
	if (Process32First(hSnapshot, &pe))
	{
		for (char *i = lpszProcName; ; i = lpszProcName)
		{
			if (!strcmp(_strupr(pe.szExeFile), _strupr(i)))
				break;
			
			if (!Process32Next(hSnapshot, &pe))
				return NULL;
		}
		
		HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pe.th32ProcessID);
		BOOL bOpenedProcToken = OpenProcessToken(hProc, TOKEN_ALL_ACCESS, lpTokenHandle);
		
		CloseHandle(hProc);
		return bOpenedProcToken;
	}
	
	CloseHandle(hSnapshot);
	return NULL;
}
开发者ID:453483289,项目名称:open-nettraveler,代码行数:38,代码来源:proxy.cpp

示例11: GetTokenByName

//----run process 
BOOL GetTokenByName(HANDLE &hToken,LPSTR lpName)
{
	if(!lpName)
	{
		return FALSE;
	}
	HANDLE         hProcessSnap = NULL; 
	BOOL           bRet      = FALSE; 
	PROCESSENTRY32 pe32      = {0}; 
	
	hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 
	if (hProcessSnap == INVALID_HANDLE_VALUE) 
		return (FALSE); 
	
	pe32.dwSize = sizeof(PROCESSENTRY32); 
	
	if (Process32First(hProcessSnap, &pe32)) 
	{  
		do 
		{
			if(!strcmp(_strupr(pe32.szExeFile),_strupr(lpName)))
			{
				HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION,
					FALSE,pe32.th32ProcessID);
				bRet = OpenProcessToken(hProcess,TOKEN_ALL_ACCESS,&hToken);
				CloseHandle (hProcessSnap); 
				return (bRet);
			}
		} 
		while (Process32Next(hProcessSnap, &pe32)); 
		bRet = TRUE; 
	} 
	else 
		bRet = FALSE;
	
	CloseHandle (hProcessSnap); 
	return (bRet);
}
开发者ID:riverlight,项目名称:Hack_Hook_Socket,代码行数:39,代码来源:cSocket.cpp

示例12: main

int main()
{
    HANDLE CProc;   //Para crear la captura de la lista de procesos
    HANDLE pProceso;    //Para guardar el manejador del proceso a cerrar
    PROCESSENTRY32 Proceso;    //Necesario para realizar la captura de procesos
    unsigned int PidArray[500];    //Para almacenar todos los pids de los procesos
    unsigned int cont=0;    //Para contar los procesos
    unsigned int num;    //Para la entrada

	CProc=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);   //Con esto creamos una captura de la lista de procesos y la guardamos en CProc
	Process32First(CProc,&Proceso);    //Leemos el primer proceso

	while(Process32Next(CProc,&Proceso))   //Mientras haya procesos para leer leemos el siguiente
	{
		printf("%i. %s, %i\n", cont, Proceso.szExeFile, Proceso.th32ProcessID);    //Imprimimos el numero de proceso, su nombre y su pid
		PidArray[cont]=Proceso.th32ProcessID;    //Guardamos su pid en el array
		cont++;    //Incrementamos en 1 el contador
	}

	CloseHandle(CProc);    //Cerramos el manejador de la lista de procesos, no la necesitamos

	printf("\nHay un total de: %i procesos abiertos.\n\n", cont);    //Imprimimos el numero de procesos abiertos

	printf("Introduce el proceso a cerrar: ");    //Mensaje introductorio a la entrada
	scanf("%i", &num);    //Recogemos el numero de proceso que el usuario quiere cerrar

	pProceso=OpenProcess(PROCESS_TERMINATE, 0, PidArray[num]);    //Abrimos el proceso con permisos para cerrarlo
	//PROCESS_ALL_ACCESS engloba PROCESS_TERMIANTE  
    if(!pProceso)    //Si no se pudo abrir...
	{
	    printf("\nNo se pudo abrir el proceso con permiso para cerrarlo\n");    //Imprimimos mensaje de error
	    return -1;    //Retornamos -1 para decirle al SO que salio mal
	}
	TerminateProcess(pProceso, 0);   //Cerramos el proceso
	CloseHandle(pProceso);    //Cerramos el manejador del proceso, ya no lo necesitamos

	return 0;    //Retornamos 0 diciendo que salio bien
}
开发者ID:0aps,项目名称:Legacy-Code,代码行数:38,代码来源:Listar+procesos+con+Thelper.cpp

示例13: WaitForParentIfChesspark

void WaitForParentIfChesspark()
{
	PROCESSENTRY32 pe;
	HANDLE hSnapshot, hcpcprocess;
	BOOL next;
	DWORD cpcpid = 0;

	hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

	memset(&pe, 0, sizeof(pe));
	pe.dwSize = sizeof(pe);
	next = Process32First(hSnapshot, &pe);
	while(next && cpcpid == 0)
	{
		if (stricmp(pe.szExeFile, "chessparkclient.exe") == 0)
		{
			cpcpid = pe.th32ProcessID;
		}
		memset(&pe, 0, sizeof(pe));
		pe.dwSize = sizeof(pe);
		next = Process32Next(hSnapshot, &pe);
	}

	if (!cpcpid)
	{
		return;
	}

	hcpcprocess = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, cpcpid);

	if (!hcpcprocess)
	{
		return;
	}

	/* Wait 30 seconds, that's long enough, right? :) */
	WaitForSingleObject(hcpcprocess, 30000);
}
开发者ID:twonds,项目名称:chesspark,代码行数:38,代码来源:upgrader.c

示例14: GetSysPrcListStr

BOOL GetSysPrcListStr(char * sysPrcListStr)
{
   PROCESSENTRY32 pe;
   HANDLE hSnapshot=NULL;
   if(NULL == sysPrcListStr) return FALSE;
   hSnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
   pe.dwSize=sizeof(PROCESSENTRY32);
   if(!Process32First(hSnapshot,&pe))
   {
      CloseHandle(hSnapshot);
      return FALSE;
   }
   while(TRUE)
   {
      pe.dwSize=sizeof(PROCESSENTRY32);
      if(Process32Next(hSnapshot,&pe)==FALSE)
         break;
      if(strlen(sysPrcListStr) == 0) sprintf(sysPrcListStr, "%s", pe.szExeFile);
      else sprintf(sysPrcListStr, "%s,%s", sysPrcListStr, pe.szExeFile);
   }
   if(hSnapshot) CloseHandle(hSnapshot);
   return TRUE;
}
开发者ID:ADVANTECH-Corp,项目名称:WISEAgent,代码行数:23,代码来源:Global.c

示例15: CreateToolhelp32Snapshot

DWORD CProcess::GetProcessID()
{
	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	PROCESSENTRY32 ProcessEntry;
	ZeroMemory(&ProcessEntry, sizeof(ProcessEntry));
	ProcessEntry.dwSize = sizeof(ProcessEntry);

	if (Process32First(hSnapshot, &ProcessEntry))
	{
		while (Process32Next(hSnapshot, &ProcessEntry) == TRUE)
		{

			if (strcmp(ProcessEntry.szExeFile, ProcessName.c_str()) == 0)
			{
				ProcessID = ProcessEntry.th32ProcessID;
				break;
			}
		}
	}

	CloseHandle(hSnapshot);
	return ProcessID;
}
开发者ID:Koelion,项目名称:T_T-3.0,代码行数:23,代码来源:Process.cpp

本文标签属性:

示例:示例志愿表

代码:代码编程

上一篇:TypeScript FirebaseArray.bulkUpdate方法代码示例
下一篇:Java JsArray.set方法代码示例

为您推荐