你是要的是暂停其他进程吗?
如果是的话,blue/aiqbird的方法是可行的,但太麻烦且不稳定
最好且最简单的方法是调用系统API:ZwSuspendProcess 挂起进程
唤醒可以用:ZwResumeProcess函数
由于这两个函数是windows的非公开函数,所以要自己声明,具体方法见网上。 答案补充 函数有一个参数,即为你要暂停的进程的句柄hprocess,句柄可以用OpenProcess获得,
然后就 ZwSuspendProcess (hprocess) 就将进程挂起了,唤醒就 ZwResumeProcess(hprocess)
你好!我给你编译一个程序:
函数名: delay
功 能: 将程序的执行暂停一段时间(毫秒)
用 法: void delay(unsigned milliseconds);
程序例:
/* Emits a 440-Hz tone for 500 milliseconds */
#include
int main(void)
{
sound(440);
delay(500);
nosound();
return 0;
} 答案补充 你有VC编译系统吗?就是把它转换成.exe文件,在系统中运行就可以了。你是学C语言的吗?
#include
#include
#include
int main(int argc, char** argv){
INT32 iProcessID;
HANDLE hProcess;
HANDLE hSnapshoHandle;
HANDLE hCurrentThread;
BOOL bIsFound;
THREADENTRY32 CThreadEny;
if(argc != 2){
printf("To want a argumen!\n");
return -1;
};
iProcessID = atoi(argv[1]);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, iProcessID);
if(hProcess == NULL){
printf("The argument is Error or the process is systemic one!\n");
return -2;
};
hSnapshoHandle = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, iProcessID);
CThreadEny.dwSize=sizeof(THREADENTRY32);
bIsFound = Thread32First(hSnapshoHandle, &CThreadEny);
while(bIsFound != FALSE){
bIsFound = Thread32Next(hSnapshoHandle, &CThreadEny);
hCurrentThread = OpenThread(THREAD_ALL_ACCESS, FALSE, CThreadEny.th32ThreadID);
if(hCurrentThread != NULL){
if(CThreadEny.th32OwnerProcessID == iProcessID)
SuspendThread(hCurrentThread);
}
};
CloseHandle(hSnapshoHandle);
printf("Successful suspend a process(PID: iProcessID)\n");
};