我用的方法是得到当前所有进程的快照。然后查找每个进程子进程,如果当前进程(我的进程)是某个进程的子进程,则认为我的程序是被别的程序调用的。如果没找到就认为是独立运行的。
但这个方法很慢,有没有快一点的方法?
但这个方法很慢,有没有快一点的方法?
解决方案 »
- VC中如何确定鼠标指针落在某图形区域内?
- 在MDI(多文档)编程下如何禁用某个菜单?
- 在VC6.0界面中将摄像机拍摄的图像实现出来
- 请问:无法声明CString类型变量.声明之后在初始化时会出错,在关闭程序时也会出错.
- 狼来了,狼来了!
- 在线等,为了这个程序,耗了我很多分!不过程序快完了!还有一个小问题的!关于SQL的!望赐教
- 下面问题不难,可我不知道!提建议者就有分!
- 如何用WTL创建菜单单选标记
- 1个小问题
- 如何得到一个文件夹下,所有文件和子文件夹的名称。象资源管理器一样。
- 请问QQ聊天记录的数据格式是怎么样的啊
- 急求:MS Visual C++1.52完整安装版,先给100分,不够另开贴加分。
#include <tlhelp32.h>
#include <stdio.h>BOOL GetProcessList ()
{
HANDLE hProcessSnap = NULL;
BOOL bRet = FALSE;
PROCESSENTRY32 pe32 = {0};
// Take a snapshot of all processes in the system. hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hProcessSnap == INVALID_HANDLE_VALUE)
return (FALSE);
// Fill in the size of the structure before using it. pe32.dwSize = sizeof(PROCESSENTRY32);
// Walk the snapshot of the processes, and for each process,
// display information. if (Process32First(hProcessSnap, &pe32))
{ do
{ // Print the process's information.
printf( "\nPriority Class Base\t%d\n", pe32.pcPriClassBase);
printf( "PID\t\t\t%d\n", pe32.th32ProcessID);
printf( "Parent PID\t\t%d\n",pe32.th32ParentProcessID);
printf( "Thread Count\t\t%d\n", pe32.cntThreads);
printf( "Full Path\t\t%s\n\n", pe32.szExeFile);
}
while (Process32Next(hProcessSnap, &pe32));
bRet = TRUE;
}
else
bRet = FALSE; // could not walk the list of processes
// Do not forget to clean up the snapshot object. CloseHandle (hProcessSnap);
return (bRet);
} int main()
{
return GetProcessList();
}