我的DLL中,有属性表和各属性页,是MFC扩展DLL。在一个ActiveX控件中调用它时,程序执行到:
--> HRSRC hResource = ::FindResource(psp.hInstance,
psp.pszTemplate, RT_DIALOG);
HGLOBAL hTemplate = LoadResource(psp.hInstance,
hResource);
pTemplate = (LPCDLGTEMPLATE)LockResource(hTemplate);
时,hResource总是为空。所以我去看DLL,发现DllMain()函数中有这么一段注释: // Extension DLL one-time initialization
if (!AfxInitExtensionModule(MemlistDLL, hInstance))
return 0; // Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result. new CDynLinkLibrary(MemlistDLL);虽然每个英文字母、单词都认识,但还是不能领悟其意?故望各位朋友以慈悲为怀,怜悯苍生之不幸,救小生于水火之中,则吾定当感激涕零,双手奉上100分。(不够的话,可以再加。)
--> HRSRC hResource = ::FindResource(psp.hInstance,
psp.pszTemplate, RT_DIALOG);
HGLOBAL hTemplate = LoadResource(psp.hInstance,
hResource);
pTemplate = (LPCDLGTEMPLATE)LockResource(hTemplate);
时,hResource总是为空。所以我去看DLL,发现DllMain()函数中有这么一段注释: // Extension DLL one-time initialization
if (!AfxInitExtensionModule(MemlistDLL, hInstance))
return 0; // Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result. new CDynLinkLibrary(MemlistDLL);虽然每个英文字母、单词都认识,但还是不能领悟其意?故望各位朋友以慈悲为怀,怜悯苍生之不幸,救小生于水火之中,则吾定当感激涕零,双手奉上100分。(不够的话,可以再加。)
解决方案 »
- 程序再次运行时,程序的什么信息会改变?
- 聊天记录在listBox中的字体颜色如何改变???
- 把向clistview中插入数据的代码从OnInitialUpdate拷贝到一个响应函数中就插入不了数据了?
- 为何断点无效
- 招集VC++高手,合伙设计开发CAD系统
- CSDN 登陆验证码 数字0和 字母O 有人能分清吗, 只有 有这两个字符之一,我就得重复试X次,建设 不要出现这两个字符
- 如何调用成员函数?
- 有用过BCG库(6.21)的请进来,如何实现TAB窗口的一些特性.
- 请问高手哪有关于c/s,b/s方面的资料?请给菜鸟提供几个比较好的网站?
- 窗口的关闭按钮
- 请问如何得到分区的Label??
- 多文档下如何增加一个视图
m_hInstOld = AfxGetResourceHandle();
AfxSetResourceHandle(TagListDLL.hResource);
在结束时,再
AfxSetResourceHandle(m_hInstOld);
这样,对于MFC应用是可以的。但这样在ActiveX控件中就是不能用,老在上面那地方出错。急死我了。
//保存当前ACTIVEX控件资源,装载TagList.DLL资源
HINSTANCE hOldInst = AfxGetResourceHandle();
HINSTANCE hTagDll = ::LoadLibrary("TagList.dll");
if(hTagDll)
AfxSetResourceHandle( hTagDll );
..................
...................
.................
之后:
//恢复保存的ACTIVEX控件资源,卸载TagList.DLL资源
if(hTagDll)
FreeLibrary(hTagDll);
AfxSetResourceHandle( hOldInst );
发现这样,竟然可以了。呵呵!不知这样有没有漏洞?请各位指正!