MFC对话框程序报错,创建对话框不成功
对话框程序的InitInstance函数源代码入下:
BOOL CSinovoApp::InitInstance(){ ShellExecute(NULL,"open","reg.bat",NULL,NULL,SW_HIDE); Sleep(1000); CExclusive exclusive; CWinApp::InitInstance(); SetPriorityClass(GetCurrentProcess(),ABOVE_NORMAL_PRIORITY_CLASS); if(PreProcessCommandLine(GetCommandLine())){ return FALSE; } if(exclusive.IsRunning("Sinovo-server")){ ReinitIcon(); return FALSE; } InitCommonControls(); AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("Sinovo")); CSinovoDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用“确定”来关闭 //对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用“取消”来关闭 //对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE;}CSinovoDlg::CSinovoDlg(CWnd* pParent /*=NULL*/) : CDialog(CSinovoDlg::IDD, pParent){ m_log.SetModule("[SinovoDlg]"); // Load icon m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); // initialize com interfaces pBroadcast = NULL; pVSServer = NULL; pRServer = NULL; pMouse = NULL; pDevice = NULL; // initialize thread variables hThread = NULL; hTimeThread = NULL; bThreadExit = FALSE; // initialize sinovo dialog elements rcWatch.left = 0; rcWatch.top = 0; rcWatch.right = 800; rcWatch.bottom = 600; bTempStopped = FALSE; bInitialized = FALSE; bPrimary = TRUE; CInterfaceHelper interfaceHelper; if(!interfaceHelper.GetServerInterface()) { AfxMessageBox("Initialize the CSLib failed"); m_log.Append("Failed to initialize CSLib, Sinovo exits."); PostQuitMessage(0); } else { Initialize(); }}