有时候我们在应用Com组件的时候,退出程序前会遇到一下警告信息:
---------------------------
COM Server Warning
---------------------------
There are still active COM objects in this application. One or more clients may have references to these objects, so manually closing this application may cause those client application(s) to fail.
Are you sure you want to close this application?
---------------------------
是(Y) 否(N)
---------------------------
在你退出程序之前这样处理就可以了:
var Factory: IClassFactory;
begin
CoGetClassObject(<你所使用的com的GUID>, CLSCTX_SERVER, nil, IClassFactory, Factory);
Factory.LockServer(False);
end
以上代码需要:ActiveX,ComServ 单元。
本文介绍了解决在退出程序时出现的COM组件警告的方法。通过使用特定的代码来释放COM对象,避免客户端应用程序因手动关闭而失败。
2548

被折叠的 条评论
为什么被折叠?



