Microsoft KB Archive/251344
Article ID: 251344
Article Last Modified on 10/17/2003
- Microsoft ActiveX Template Library 3.0, when used with:
- Microsoft Visual C++ 6.0 Enterprise Edition
This article was previously published under Q251344
If you have used the CComBSTR class in a non-ATL application and used the bool CComBSTR::LoadString(UINT nID) function, it might give an access violation.
The global _pModule variable representing an instance of CComModule expected by ATL, is not declared and initialized.
Use the other overloaded version of LoadString that takes HINSTANCE as a parameter
bool CComBSTR::LoadString(HINSTANCE hInst, UINT nID)
and pass the HINSTANCE of the current module or the module wherever the string resource is defined.
Or, add ATL support to this project. In order to add ATL support, from the Insert menu, click New ATL Object. You are then asked if you want to add ATL support to this project; click Yes. As a result, the ATL Object Wizard is opened. Cancel that option if you do not want to add an ATL object to your project.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Steps to Reproduce Behavior
- Generate a new MFC AppWizard SDI application.
- Go to ResourceView and add a new string entry to the String Table resource and call it IDS_TESTSTRING.
Go to CYourApp::InitInstance and add the following code:
CComBSTR bstrTemp; bstrTemp.LoadString(IDS_TESTSTRING);
- Also add #include AtlBase.h to the .cpp file containing the above code for InitInstance.
- Build and run it. You receive the access violation.
Additional query words: CString stringtable unexpected MFC
Keywords: kbbug kbarchitecture kbstring kbpending KB251344