ocx Exitinstance GdiplusShutdown ActiveX gdi+问

来源:互联网 发布:知而谨之 编辑:程序博客网 时间:2024/05/23 18:14

在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


原创粉丝点击