English 中文(简体)
如何镇压 在最后申请时,“在这种申请中,仍然有现役的COM物体”错误?
原标题:How to suppress "There are still active COM objects in this application" error when closing application?

我撰写了几件ATL COM物体,这些物体在我的C++范围内用于拖累和空投。 建筑应用。

Due to reasons beyond my control, my application still has active COM objects when the user attempts to close it. This is because other COM clients that use my objects seem to cache my COM objects and don t release them - as a result, my COM objects still have a reference count greater than zero when the user clicks the "X" to close my program. This results in the user getting an unfriendly message like this:

“entergraph

I would like my application to silently terminate and not ask the user this annoying question.

我如何压制这一信息?

最佳回答

人口信息由<代码>显示。 TATLModule:AutomationTerminateProc( callsback function in atlmod.h. 登记在<代码>TATLModule:InitATLServer(,其中称VCL s代码<>AddTerminateProc()。 当使用<代码>TForm:Close()方法时,请CallTerminationProcs(,以确保该仪器能够安全关闭,然后打电话TATLModule:AutomationTerminateProc()。

。 为了避免登峰造物,简单地通过你的项目主要文件,所有文件都填写了<条码>。

void __fastcall MyInitATLServer();

TComModule _ProjectModule(&MyInitATLServer); // <-- here
TComModule &_Module = _ProjectModule;

BEGIN_OBJECT_MAP(ObjectMap)
  ...
END_OBJECT_MAP()

void __fastcall MyInitATLServer()
{
    if (TComModule::SaveInitProc)
        TComModule::SaveInitProc();

    _Module.Init(ObjectMap, Sysinit::HInstance);
    _Module.m_ThreadID = ::GetCurrentThreadId();
    _Module.m_bAutomationServer = true;
    _Module.DoFileAndObjectRegistration();
    // AddTerminationProc(AutomationTerminationProc); // <-- no more popup!
}
问题回答

我就此找到了工作。 如果有人要找到更好的方法,我就不谈这个问题,因为这种方法取决于C++建筑商/科索沃渔业委员会图书馆的无证内部执行细节。

主要形式是:

extern TComModule &_Module;
void __fastcall TMainAppForm::FormCloseQuery(TObject *Sender, bool &CanClose)
{
    _Module.m_nLockCnt = 0;

VCL似乎检查了锁定点,并展示了这一信息 > 之后的“ ” 。 只有在锁定点数为0时,才会显示信息。 因此,我把钟点定在零点上,使信息无法显示。 我认为,这样做是无益的,因为我搜索了ATL/VCL的源码,用于24小时计数的地方,而且我发现除了守则之外,没有任何东西可以检查是否显示这一信息。

提 出

TerminateProcess(GetCurrentProcess(), 0);

当然,如果没有更好的办法。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?