| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1223 人关注过本帖
标题:[解決中] 關於在 XP 如何正常調用 TerminateProcess 函數
只看楼主 加入收藏
yeshirow
Rank: 4
等 级:贵宾
威 望:10
帖 子:854
专家分:0
注 册:2006-6-8
收藏
 问题点数:0 回复次数:4 
[解決中] 關於在 XP 如何正常調用 TerminateProcess 函數
#include <iostream>
#include <windows.h>

void main(void)
{
int i;
std::cout << "Enter something and press to Terminate:" << std::endl;
std::cin >> i;
TerminateProcess((HANDLE)2036L, 1);
// 2036 是我從任務管理器中得到的 PID, 是有效的
std::cout << "handle terminated!" << std::endl;
std::cin >> i;
}

爲甚麽現在( XP 系統) TerminateProcess 不能正常工作了, 以前 ( 非 XP 系統) 是可以的啊

[此贴子已经被作者于2006-7-21 1:45:15编辑过]

搜索更多相关主题的帖子: 解決中 windows color std 
2006-07-07 13:52
yeshirow
Rank: 4
等 级:贵宾
威 望:10
帖 子:854
专家分:0
注 册:2006-6-8
收藏
得分:0 
怎麽就沒有幫下我呢.....................................

原來朋友仔感情再天真, 亦是我永遠也會愛惜的人, 明日愛他人, 也記住學會不要緊; 原來朋友比戀人更高分, 亦讓我開始懂得不記恨, 若大家都敏感, 我更要永遠記得拒絕再因小事怪人, 爲何沒有這條校訓...Twins-朋友仔 MCSD Training
2006-07-07 14:07
论坛
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1372
专家分:0
注 册:2006-3-27
收藏
得分:0 
too too hard

日出东方,唯我不败! 做任何东西都是耐得住寂寞,任何一个行业要有十年以上的积累才能成为专家
2006-07-07 14:38
lj_860603
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:714
专家分:0
注 册:2006-1-25
收藏
得分:0 

这种问题楼主应该先MAN一下啊!下面是函数在MSDN中的解释!
-------------------------------------------
Terminates the specified process and all of its threads.

Copy CodeBOOL WINAPI TerminateProcess(
HANDLE hProcess,
UINT uExitCode
);


Parameters
hProcess
[in] A handle to the process to be terminated.
The handle must have the PROCESS_TERMINATE access right. For more information, see Process Security and Access Rights.

uExitCode
[in] The exit code to be used by the process and threads terminated as a result of this call. Use the GetExitCodeProcess function to retrieve a process's exit value. Use the GetExitCodeThread function to retrieve a thread's exit value.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
The TerminateProcess function is used to unconditionally cause a process to exit. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.

TerminateProcess initiates termination and returns immediately. This stops execution of all threads within the process and requests cancellation of all pending I/O. The terminated process cannot exit until all pending I/O has been completed or canceled.

A process cannot prevent itself from being terminated.


我的原则很简单:不做不喜欢的事!
2006-07-07 18:53
yeshirow
Rank: 4
等 级:贵宾
威 望:10
帖 子:854
专家分:0
注 册:2006-6-8
收藏
得分:0 
原來是訪問權限..
謝謝了

原來朋友仔感情再天真, 亦是我永遠也會愛惜的人, 明日愛他人, 也記住學會不要緊; 原來朋友比戀人更高分, 亦讓我開始懂得不記恨, 若大家都敏感, 我更要永遠記得拒絕再因小事怪人, 爲何沒有這條校訓...Twins-朋友仔 MCSD Training
2006-07-07 19:06
快速回复:[解決中] 關於在 XP 如何正常調用 TerminateProcess 函數
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.038391 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved