ocx Exitinstance GdiplusShutdown ActiveX gdi+问

本文探讨了在VC环境下使用GDI+时出现的死锁问题,特别是在App::ExitInstance调用GdiplusShutdown函数时。文章提供了三种解决方案,并强调在ActiveX环境中正确调用GdiplusStartup与GdiplusShutdown的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在vc加入gdi+时在app::Exitinstance 调用GdiplusShutdown函数会出现卡死现象,如注册控件时候regsvr32卡死,运行控件退出时卡死/挂上.解决这个更文字在于,在其他地方初始化gdi+和清除gdi+,如框架构造和析构函数实现


但是如果是在Activex中则需要改变。

 GdiplusStartup 和GdiplusShutdown不能在dllmain中被调用,因为activex中的App类的Initinstance是在dllmain中被调用的,因此也不能在activex app类中的initinstance中调用,否则可能会导致死锁。

解决办法

msdn

1 Require your clients to call GdiplusStartup before they call the functions in your DLL and to call GdiplusShutdown when they have finished using your DLL. 

 

2 Export your own startup function that calls GdiplusStartup and your own shutdown function that calls GdiplusShutdown. Require your clients to call your startup function before they call other functions in your DLL and to call your shutdown function when they have finished using your DLL. 

 

3 Call GdiplusStartup and GdiplusShutdown in each of your functions that make GDI+ calls. 


另:这个帖子中有相关的讨论

http://topic.csdn.net/u/20111005/16/d353c25a-b269-4ecb-8a6b-c1af2341d7f1.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值