下面是Initialize 函数的代码if (!ProcessShellCommand(cmdInfo))总是在运行时报错。 // Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif // Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("PDMFramework 2004 系统集成管理"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
if (!CVCETLibrary::Initialize("TestMarkup.ini", 0))
{
AfxMessageBox("Failed to load VCET controls.");
return FALSE;
} if(!InitUserInfoDatabase("UsersInfoODBC", "PDM", "123456"))
{
AfxMessageBox("系统未能连接到用户管理数据库,请确定数据库的连接是否正常!");
return FALSE;
}
CLogInDlg LogInDlg;
LogInDlg.DoModal();
if(LogInDlg.m_bValidAccess == FALSE) return FALSE;
m_strLog = LogInDlg.m_strUserName;
m_dwRights = LogInDlg.m_dwRights;
m_strElecSignature = LogInDlg.m_strElecSignature;
// show the welcom screen.
CWzdSplash wndSplash;
wndSplash.Create(IDB_WELCOMSCREEN);
wndSplash.UpdateWindow(); //send WM_PAINT if(!InitEncodeDatabase("EncodeManageODBC", "PDM", "123456"))
{
AfxMessageBox("系统未能连接到编码管理数据库,请确定数据库的连接是否正常!");
return FALSE;
}
if(!InitEncodeList())
{
AfxMessageBox("系统编码初始化失败,系统将自动退出!");
return FALSE;
} if(!InitMainDatabase("MainDatabaseODBC", "PDM", "123456"))
{
AfxMessageBox("系统未能连接到文档数据库,请确定数据库的连接是否正常!");
return FALSE;
} if(!InitWorkFlowDatabase("WorkflowODBC", "PDM", "123456"))
{
AfxMessageBox("系统未能连接到流程管理数据库,请确定数据库的连接是否正常!");
return FALSE;
}
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
m_pDesignSpaceTemplate = new CMultiDocTemplate(
IDR_DESIGNSPACE,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CDesignSpaceChildFrame), // custom MDI child frame
RUNTIME_CLASS(CDesignView));
AddDocTemplate(m_pDesignSpaceTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame; // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
//cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE; // The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
CWnd* pWnd = pMainFrame->MDIGetActive();
if(pWnd)
pMainFrame->MDIMaximize(pWnd); pMainFrame->UpdateWindow(); m_pDesignSpaceTemplate = new CMultiDocTemplate(
IDR_DESIGNSPACE,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CDesignSpaceChildFrame), // custom MDI child frame
RUNTIME_CLASS(CDesignView));
AddDocTemplate(m_pDesignSpaceTemplate);
// add other templates.
m_pDocManagerTemplate = new CMultiDocTemplate(
IDR_CHECKIN,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CDocManagerChildFrame), // custom MDI child frame
RUNTIME_CLASS(CAihuiWorkspaceViewEx));
AddDocTemplate(m_pDocManagerTemplate); m_pPSETemplate = new CMultiDocTemplate(
IDR_PSEDIT,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CPSEChildFrame), // custom MDI child frame
RUNTIME_CLASS(CPSELeftView));
AddDocTemplate(m_pPSETemplate);
m_pSearchTemplate = new CMultiDocTemplate(
IDR_SEARCH,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CSearchChildFrame), // custom MDI child frame
RUNTIME_CLASS(CAihuiWorkspaceViewEx));
AddDocTemplate(m_pSearchTemplate);
m_pWorkFlowTemplate = new CMultiDocTemplate(
IDR_WORKFLOWMANAGER,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CWorkFlowChildFrame), // custom MDI child frame
RUNTIME_CLASS(CWorkFlowPacketsView));
AddDocTemplate(m_pWorkFlowTemplate); m_pMonitorFlowsTemplate = new CMultiDocTemplate(
IDR_MONITORFLOWSFRAME,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CMonitorFlowsChildFrame), // custom MDI child frame
RUNTIME_CLASS(CWorkFlowPacketsView));
AddDocTemplate(m_pMonitorFlowsTemplate);
// 3D HIGHLIGHT CODE
CMenu * pMenu = pMainFrame->GetMenu();
pMainFrame->cSpawn.RemapMenu(pMenu);
pMainFrame->SetMenu(pMenu);
pMainFrame->DrawMenuBar();
// 3D HIGHLIGHT CODE END
return TRUE;
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif // Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("PDMFramework 2004 系统集成管理"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
if (!CVCETLibrary::Initialize("TestMarkup.ini", 0))
{
AfxMessageBox("Failed to load VCET controls.");
return FALSE;
} if(!InitUserInfoDatabase("UsersInfoODBC", "PDM", "123456"))
{
AfxMessageBox("系统未能连接到用户管理数据库,请确定数据库的连接是否正常!");
return FALSE;
}
CLogInDlg LogInDlg;
LogInDlg.DoModal();
if(LogInDlg.m_bValidAccess == FALSE) return FALSE;
m_strLog = LogInDlg.m_strUserName;
m_dwRights = LogInDlg.m_dwRights;
m_strElecSignature = LogInDlg.m_strElecSignature;
// show the welcom screen.
CWzdSplash wndSplash;
wndSplash.Create(IDB_WELCOMSCREEN);
wndSplash.UpdateWindow(); //send WM_PAINT if(!InitEncodeDatabase("EncodeManageODBC", "PDM", "123456"))
{
AfxMessageBox("系统未能连接到编码管理数据库,请确定数据库的连接是否正常!");
return FALSE;
}
if(!InitEncodeList())
{
AfxMessageBox("系统编码初始化失败,系统将自动退出!");
return FALSE;
} if(!InitMainDatabase("MainDatabaseODBC", "PDM", "123456"))
{
AfxMessageBox("系统未能连接到文档数据库,请确定数据库的连接是否正常!");
return FALSE;
} if(!InitWorkFlowDatabase("WorkflowODBC", "PDM", "123456"))
{
AfxMessageBox("系统未能连接到流程管理数据库,请确定数据库的连接是否正常!");
return FALSE;
}
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
m_pDesignSpaceTemplate = new CMultiDocTemplate(
IDR_DESIGNSPACE,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CDesignSpaceChildFrame), // custom MDI child frame
RUNTIME_CLASS(CDesignView));
AddDocTemplate(m_pDesignSpaceTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame; // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
//cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE; // The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
CWnd* pWnd = pMainFrame->MDIGetActive();
if(pWnd)
pMainFrame->MDIMaximize(pWnd); pMainFrame->UpdateWindow(); m_pDesignSpaceTemplate = new CMultiDocTemplate(
IDR_DESIGNSPACE,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CDesignSpaceChildFrame), // custom MDI child frame
RUNTIME_CLASS(CDesignView));
AddDocTemplate(m_pDesignSpaceTemplate);
// add other templates.
m_pDocManagerTemplate = new CMultiDocTemplate(
IDR_CHECKIN,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CDocManagerChildFrame), // custom MDI child frame
RUNTIME_CLASS(CAihuiWorkspaceViewEx));
AddDocTemplate(m_pDocManagerTemplate); m_pPSETemplate = new CMultiDocTemplate(
IDR_PSEDIT,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CPSEChildFrame), // custom MDI child frame
RUNTIME_CLASS(CPSELeftView));
AddDocTemplate(m_pPSETemplate);
m_pSearchTemplate = new CMultiDocTemplate(
IDR_SEARCH,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CSearchChildFrame), // custom MDI child frame
RUNTIME_CLASS(CAihuiWorkspaceViewEx));
AddDocTemplate(m_pSearchTemplate);
m_pWorkFlowTemplate = new CMultiDocTemplate(
IDR_WORKFLOWMANAGER,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CWorkFlowChildFrame), // custom MDI child frame
RUNTIME_CLASS(CWorkFlowPacketsView));
AddDocTemplate(m_pWorkFlowTemplate); m_pMonitorFlowsTemplate = new CMultiDocTemplate(
IDR_MONITORFLOWSFRAME,
RUNTIME_CLASS(CAihuiWorkspaceDocEx),
RUNTIME_CLASS(CMonitorFlowsChildFrame), // custom MDI child frame
RUNTIME_CLASS(CWorkFlowPacketsView));
AddDocTemplate(m_pMonitorFlowsTemplate);
// 3D HIGHLIGHT CODE
CMenu * pMenu = pMainFrame->GetMenu();
pMainFrame->cSpawn.RemapMenu(pMenu);
pMainFrame->SetMenu(pMenu);
pMainFrame->DrawMenuBar();
// 3D HIGHLIGHT CODE END
return TRUE;
试试,如果还出错就应该是其他的地方出错了,否则就是你新建文件的地方有不妥的地方!