| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1317 人关注过本帖
标题:控制EXE文件的运行
只看楼主 加入收藏
wwl568
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-3-15
收藏
 问题点数:0 回复次数:13 
控制EXE文件的运行
如何用C语言编个程序,控制某个EXE程序的运行,想要这个EXE运行必须输入密码.
有强人没有呀??????
搜索更多相关主题的帖子: EXE 文件 运行 C语言 
2008-04-28 17:28
wwl568
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-3-15
收藏
得分:0 
自己沙发个

魔风铃
2008-04-28 17:29
yxwsbobo
Rank: 5Rank: 5
等 级:职业侠客
帖 子:345
专家分:306
注 册:2007-10-29
收藏
得分:0 
ShellExecuteEx搜哈

How are you 怎么是你?
How old are you   怎么老是你?
2008-04-28 17:35
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
你是要控制自己的程序还是控制其他人的程序
2008-04-28 19:08
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
用钩子钩住线程呢?谈出对话框..密码不对,就关闭线程...

学习需要安静。。海盗要重新来过。。
2008-04-28 19:17
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
这个应该做成一个嵌入到程序本身的
2008-04-28 19:27
wwl568
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-3-15
收藏
得分:0 
多谢楼上各位.
这个功能是不是实现起来很复杂呀.
我是想控制别人的程序,
比如:在"讯雷"运行时必须输入密码.

[[it] 本帖最后由 wwl568 于 2008-4-29 09:20 编辑 [/it]]

魔风铃
2008-04-29 09:00
wwl568
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-3-15
收藏
得分:0 
[bo]以下是引用 [un]sunkaidong[/un] 在 2008-4-28 19:17 的发言:[/bo]

用钩子钩住线程呢?谈出对话框..密码不对,就关闭线程...

请问:能具体点吗,偶是新手,怎么钩呀.

[[it] 本帖最后由 wwl568 于 2008-4-29 09:19 编辑 [/it]]

魔风铃
2008-04-29 09:02
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
SetWindowsHookEx
The SetWindowsHookEx function installs an application-defined hook procedure into a hook chain. You would install a hook procedure to monitor the system for certain types of events. These events are associated either with a specific thread or with all threads in the system.

HHOOK SetWindowsHookEx(
  int idHook,        // type of hook to install
  HOOKPROC lpfn,     // address of hook procedure
  HINSTANCE hMod,    // handle to application instance
  DWORD dwThreadId   // identity of thread to install hook for
);
 
Parameters
idHook
Specifies the type of hook procedure to be installed. This parameter can be one of the following values: Value Description
WH_CALLWNDPROC Installs a hook procedure that monitors messages before the system sends them to the destination window procedure. For more information, see the CallWndProc hook procedure.
WH_CALLWNDPROCRET Installs a hook procedure that monitors messages after they have been processed by the destination window procedure. For more information, see the CallWndRetProc hook procedure.
WH_CBT Installs a hook procedure that receives notifications useful to a computer-based training (CBT) application. For more information, see the CBTProc hook procedure.
WH_DEBUG Installs a hook procedure useful for debugging other hook procedures. For more information, see the DebugProc hook procedure.
WH_FOREGROUNDIDLE Installs a hook procedure that will be called when the application's foreground thread is about to become idle. This hook is useful for performing low priority tasks during idle time. For more information, see the ForegroundIdleProc hook procedure.  
WH_GETMESSAGE Installs a hook procedure that monitors messages posted to a message queue. For more information, see the GetMsgProc hook procedure.
WH_JOURNALPLAYBACK Installs a hook procedure that posts messages previously recorded by a WH_JOURNALRECORD hook procedure. For more information, see the JournalPlaybackProc hook procedure.
WH_JOURNALRECORD Installs a hook procedure that records input messages posted to the system message queue. This hook is useful for recording macros. For more information, see the JournalRecordProc hook procedure.
WH_KEYBOARD Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure.
WH_KEYBOARD_LL Windows NT: Installs a hook procedure that monitors low-level keyboard input events. For more information, see the LowLevelKeyboardProc hook procedure.
WH_MOUSE Installs a hook procedure that monitors mouse messages. For more information, see the MouseProc hook procedure.
WH_MOUSE_LL Windows NT: Installs a hook procedure that monitors low-level mouse input events. For more information, see the LowLevelMouseProc hook procedure.
WH_MSGFILTER Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar. For more information, see the MessageProc hook procedure.
WH_SHELL Installs a hook procedure that receives notifications useful to shell applications. For more information, see the ShellProc hook procedure.
WH_SYSMSGFILTER Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar. The hook procedure monitors these messages for all applications in the system. For more information, see the SysMsgProc hook procedure.


lpfn
Pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a dynamic-link library (DLL). Otherwise, lpfn can point to a hook procedure in the code associated with the current process.
hMod
Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.
dwThreadId
Specifies the identifier of the thread with which the hook procedure is to be associated. If this parameter is zero, the hook procedure is associated with all existing threads.
Return Values
If the function succeeds, the return value is the handle to the hook procedure.

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

Remarks
An error may occur if the hMod parameter is NULL and the dwThreadId parameter is zero or specifies the identifier of a thread created by another process.

Calling the CallNextHookEx function to chain to the next hook procedure is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call CallNextHookEx unless you absolutely need to prevent the notification from being seen by other applications.

Before terminating, an application must call the UnhookWindowsHookEx function to free system resources associated with the hook.

The scope of a hook depends on the hook type. Some hooks can be set only with system scope; others can also be set for only a specific thread, as shown in the following list:

Hook Scope
WH_CALLWNDPROC Thread or system
WH_CALLWNDPROCRET Thread or system
WH_CBT Thread or system
WH_DEBUG Thread or system
WH_FOREGROUNDIDLE Thread or system
WH_GETMESSAGE Thread or system
WH_JOURNALPLAYBACK System only
WH_JOURNALRECORD System only
WH_KEYBOARD Thread or system
WH_KEYBOARD_LL Thread or system
WH_MOUSE Thread or system
WH_MOUSE_LL Thread or system
WH_MSGFILTER Thread or system
WH_SHELL Thread or system
WH_SYSMSGFILTER System only


For a specified hook type, thread hooks are called first, then system hooks.

The system hooks are a shared resource, and installing one affects all applications. All system hook functions must be in libraries. System hooks should be restricted to special-purpose applications or to use as a development aid during application debugging. Libraries that no longer need a hook should remove the hook procedure.

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also
Hooks Overview, Hook Functions, CallNextHookEx, CallWndProc, CallWndRetProc, CBTProc, DebugProc, ForegroundIdleProc, GetMsgProc, JournalPlaybackProc, JournalRecordProc, LowLevelKeyboardProc, LowLevelMouseProc KeyboardProc, MouseProc, MessageProc, ShellProc, SysMsgProc, UnhookWindowsHookEx

 这个是msdn上的钩子函数...可以钩住鼠标键盘以及其他很多东西...你可以自己先看看写写...

学习需要安静。。海盗要重新来过。。
2008-04-29 10:38
SNAKEQX
Rank: 1
等 级:新手上路
帖 子:112
专家分:3
注 册:2006-4-11
收藏
得分:0 
楼上专业阿!!!!!铁钩船长函数很难理解阿!
2008-04-29 12:16
快速回复:控制EXE文件的运行
数据加载中...
 
   



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

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