Article ID: 160909
Article Last Modified on 11/18/2003
Excel Worksheet:
DefaultExtension = .xls, Excel Workbook (*.xls)
AppWizard app named 'Test' with .tst extension:
DefaultExtension = Test, Test Files (*.tst)
DefaultExtension = .tst, Test Files (*.tst)the Binder will then display the icon defined for the document object.
/* Compile options needed: None
*/
/* The following code can be added to the InitInstance of the CWinApp
derived class right after the call to UpdateRegistry()
*/
// change the DefaultExtension to work with Binder95.
// Get registration info from document template string.
CString strServerName;
CString strLocalServerName;
CString strLocalShortName;
CString strLocalFilterName;
CString strLocalFilterExt;
if (!pDocTemplate->GetDocString(strServerName,
CDocTemplate::regFileTypeId) || strServerName.IsEmpty())
{
TRACE0("Error: not enough information in DocTemplate to register"
" OLE server.\n");
}
if (!pDocTemplate->GetDocString(strLocalServerName,
CDocTemplate::regFileTypeName))
strLocalServerName = strServerName; // use non-localized name
if (!pDocTemplate->GetDocString(strLocalShortName,
CDocTemplate::fileNewName))
strLocalShortName = strLocalServerName; // use long name
pDocTemplate->GetDocString(strLocalFilterName,
CDocTemplate::filterName);
pDocTemplate->GetDocString(strLocalFilterExt, CDocTemplate::filterExt);
ASSERT(strServerName.Find(' ') == -1); // no spaces allowed
// place entries in system registry
LPCTSTR Arr[2];
CString strDefExt("CLSID\\%1\\DefaultExtension");
CString strEntry = strDefExt + (TCHAR)NULL + strLocalFilterExt + ","
+ strLocalFilterName;
Arr[0] = strEntry;
Arr[1] = NULL;
if (!AfxOleRegisterServerClass(m_server.GetClassID(), strServerName,
strLocalShortName, strLocalServerName, OAT_DOC_OBJECT_SERVER,
NULL, Arr))
{
// not fatal (don't fail, just warn)
AfxMessageBox(AFX_IDP_FAILED_TO_AUTO_REGISTER);
}
Additional query words: DocObject ActiveX
Keywords: kbbug kbfix kbregistry kbnoupdate kbactivedocs kbvc600fix KB160909