陷阱Ctrl-C,怎么样? [英] Trapping Ctrl-C, how?

查看:86
本文介绍了陷阱Ctrl-C,怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在研究的lib有点问题。首先,

问题是我所拥有的lib连接到DirectSound,而

有许多自定义的声音相关功能。现在,在lib中是一个

''destroy''函数,当调用它时会释放我创建的所有

DirectSound实例,如果使用它,那么很棒没问题。

使用这个lib的应用程序是一个运行在

WindowsNT 4.0 sp6上的控制台应用程序,在连接到这个lib之前,如果我们想要杀死它/>
应用程序我们只需按Ctrl + C就可以了。但是现在它已经连接到了我的lib上的
,如果我们执行一个Ctrl + C而不是应用程序消失它会挂起并且时间

out,这对于我们的使用来说是不可思议的。所以要解决这个问题,我必须找到一种陷阱,当用户点击Ctrl + C并调用我自己的

''destroy''函数然后释放按Ctrl + C回到操作系统,或者,必须在
中找到一种方法在DirectSound中配置它,这样如果控制应用程序

死掉,创建的对象会自动释放(我已经找到了b $ b,但是找不到了。)


所以....感谢您阅读这篇文章!,有谁知道如何去做这个?。承担

,我无法控制窗口的创建(我找到了一组

的功能,看起来他们会做的,WindowProc和朋友

但是他们需要在窗口创建时完全设置,我不能这样做。 Ive

尝试了SetWindowsHookEx系列功能但出于某种原因

我根本无法触发任何测试钩子而且我被告知他们可能会

与控制台应用程序无法正常运行。


任何输入都会非常感激,在这里发布或者如果你愿意的话,请直接发邮件给我b $ b :pforan AT cae DOT com


TIA!


Phil

Hi all,

Got a little problem with a lib that I''m working on. First of all, the
problem is that the lib that I have makes connections to DirectSound, and
has a host of custom built sound related functions. Now, in the lib is a
''destroy'' function which when called will release all instances of
DirectSound that I have created and if that is used, then great, no problem.
The application that uses this lib is a console application running on
WindowsNT 4.0 sp6, and before connecting to this lib, if we wanted to kill
the app we simply hit Ctrl+C and it dies. But now that its been connected to
my lib, if we do a Ctrl+C instead of the app dissapearing it hangs and times
out which unfortunately is unnaceptable for our usage. So to solve this, I
either have to find a way to trap when the user hits Ctrl+C and call my own
''destroy'' function before releasing the Ctrl+C back to the OS, or, have to
find a way in DirectSound to configure it so that if the controlling app
dies, the objects created are released automatically (this I''ve already
looked for and cant find).

So.... thanks for reading this far!, does anyone know how to do this?. Bear
in mind, I have no control over the creation of the window (I found a group
of functions which seem that they would do the job, WindowProc and friends
but they need to be fully setup at the window creation which I cant do). Ive
tried the SetWindowsHookEx family of functions but for one reason or another
I cannot get any test hooks to trigger at all and I was told that they may
not function properly with console applications.

Any input at all would be greatly appreciated, post here or if you prefer
mail me directly at: pforan AT cae DOT com

TIA!

Phil

推荐答案

Wurm写道:

大家好,

有点问题[...]

Hi all,

Got a little problem [...]



....恰好是comp.lang.c中的问题19.38

常见问题(FAQ)列表

http://www.eskimo.com/~scs/C-faq/top .html


-
Er ** *******@sun.com



.... which happens to be Question 19.38 in the comp.lang.c
Frequently Asked Questions (FAQ) list

http://www.eskimo.com/~scs/C-faq/top.html

--
Er*********@sun.com




Eric Sosman< Er ********* @ sun.com>在消息中写道

新闻:3F *************** @ sun.com ...

Eric Sosman <Er*********@sun.com> wrote in message
news:3F***************@sun.com...
Wurm写道:

大家好,

有点问题[...]

Hi all,

Got a little problem [...]



...恰好是问题19.38在comp.lang.c
常见问题(FAQ)列表

http://www.eskimo.com/~scs/C-faq/top.html

-
Er*********@sun.com




好​​儿子.......,谢谢!生病需要花一些时间看看

常见问题解答,甚至不知道它在那里:)


Wurm



Well son-of-a......., thanks!. Ill definetly take some time and look through
that FAQ, didnt even know it was there :)

Wurm


Eric Sosman写道:
Eric Sosman wrote:
Wurm写道:
Wurm wrote:
有一点问题[...]
Got a little problem [...]



...恰好是comp.lang.c中的问题19.38
常见问题(FAQ)列表

http://www.eskimo.com/~scs/C-faq/top.html




优秀答案!



Excellent answer!


这篇关于陷阱Ctrl-C,怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆