分享

为什么在运行if (!ProcessShellCommand(cmdInfo))后出现 xxx.exe中的 0x5d1876e4 处最可能的异常: 0xC000

 牛人的尾巴 2017-01-10
/C++ code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
BOOL CUIDemoApp::InitInstance()
{
    // 如果一个运行在 Windows XP 上的应用程序清单指定要
    // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
    //则需要 InitCommonControlsEx()。否则,将无法创建窗口。
    connPool= Connection_pool::GetInstance();
    //InItDBConnPool(".","","","viewdb",5, 25); 
    exePath=(LPCSTR)AfxGetApp()->m_pszHelpFilePath;   
    CString str=AfxGetApp()->m_pszExeName;  
     
    exePath=exePath.substr(0,exePath.length()-str.GetLength()-4);  
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    // 将它设置为包括所有要在应用程序中使用的
    // 公共控件类。
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);
    CWinAppEx::InitInstance();
    string path;
    path=exePath+"Connect.ini";
     
    CString ConnectTypeCS;   
    CString ConnectIPC;
    CString ConnectPORTC;
    GetPrivateProfileString(_T("Connect"),_T("ConnectType"),_T(""),ConnectTypeCS.GetBuffer(MAX_PATH),MAX_PATH,(LPCSTR)path.c_str());
    GetPrivateProfileString(_T("Connect"),_T("IP"),_T(""),ConnectIPC.GetBuffer(MAX_PATH),MAX_PATH,(LPCSTR)path.c_str());
    GetPrivateProfileString(_T("Connect"),_T("PORT"),_T(""),ConnectPORTC.GetBuffer(MAX_PATH),MAX_PATH,(LPCSTR)path.c_str());
    GetPrivateProfileString(_T("Connect"),_T("ID"),_T(""),ipid.GetBuffer(MAX_PATH),MAX_PATH,(LPCSTR)path.c_str());   
    ConnectIP=ConnectIPC.GetBuffer(0);
    ConnectIPC.ReleaseBuffer();
    ConnectPORT=ConnectPORTC.GetBuffer(0);
    ConnectPORTC.ReleaseBuffer();
    ipid.ReleaseBuffer();
    transform(ConnectType.begin(), ConnectType.end(), ConnectType.begin(), toupper);
    CDlgLogon dlg;
     
    int count = 0;
    do
    {
        if(count >= 3)
        {
            ::MessageBox(NULL, _T("三次登录尝试失败!"), _T("系统提示"), MB_OK);
            return true;
        }
        dlg.m_user = _T("");
        dlg.m_password = _T("");
        dlg.m_ConnectType.Format(_T("%s"),ConnectTypeCS);
        //    =ConnectTypeCS;
        dlg.m_IP.Format(_T("%s"),ConnectIP.c_str());
        dlg.m_Port.Format(_T("%s"),ConnectPORT.c_str());;
         
        if(dlg.DoModal() == IDOK)
        {   
             
            if(ValidUser(dlg.m_user,dlg.m_password))               
            {
                 
                 
                UserName=dlg.m_user;
                WritePrivateProfileString(_T("Connect"),_T("ConnectType"),dlg.m_ConnectType,(LPCSTR)(LPCWSTR)path.c_str());
                WritePrivateProfileString(_T("Connect"),_T("IP"),dlg.m_IP,(LPCSTR)(LPCWSTR)path.c_str());
                WritePrivateProfileString(_T("Connect"),_T("PORT"),dlg.m_Port,(LPCSTR)(LPCWSTR)path.c_str());
                ConnectType=dlg.m_ConnectType.GetBuffer(0);
                dlg.m_ConnectType.ReleaseBuffer();
                if (ConnectType=="SERVER")
                {
                    ConnectPORT=dlg.m_Port.GetBuffer(0);
                    dlg.m_Port.ReleaseBuffer();
                    ServerConnect(ConnectPORT);
                     
                }
                else
                {
                     
                    ConnectIP=dlg.m_IP.GetBuffer(0);
                    dlg.m_IP.ReleaseBuffer();
                    ConnectPORT=dlg.m_Port.GetBuffer(0);
                    dlg.m_Port.ReleaseBuffer();
                    ClientConnect(ConnectIP,ConnectPORT);
                }
                 
                break;
            }
            else
            {
                count++;
            }       
        }
        else
        {
            return true;
        }
    }while(1);
    // 初始化 OLE 库
    if (!AfxOleInit())
    {
        AfxMessageBox(IDP_OLE_INIT_FAILED);
        return FALSE;
    }
    AfxEnableControlContainer();
    InitShellManager();//初始化CMFCShellTreeCtrl和CMFCShellListCtrl
    // 标准初始化
    // 如果未使用这些功能并希望减小
    // 最终可执行文件的大小,则应移除下列
    // 不需要的特定初始化例程
    // 更改用于存储设置的注册表项
    // TODO: 应适当修改该字符串,
    // 例如修改为公司或组织名
    //lbw
    SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
    LoadStdProfileSettings(0);  // 加载标准 INI 文件选项
    InitContextMenuManager();
    InitKeyboardManager();
    InitTooltipManager();
    CMFCToolTipInfo ttParams;
    ttParams.m_bVislManagerTheme = TRUE;
    theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
    // 注册应用程序的文档模板。文档模板
    // 将用作文档、框架窗口和视图之间的连接
    CSingleDocTemplate* pDocTemplate;
    pDocTemplate = new CSingleDocTemplate(
        IDR_MAINFRAME,
        RUNTIME_CLASS(CUIDemoDoc),
        RUNTIME_CLASS(CMainFrame),       // 主 SDI 框架窗口
        RUNTIME_CLASS(CAdminList));
    if (!pDocTemplate)
        return FALSE;
    AddDocTemplate(pDocTemplate);
    //CMainFrame cmainFrame;
    //cmainFrame.OnQueryAdmin();
    // 启用“DDE 执行”
    EnableShellOpen();
    RegisterShellFileTypes(TRUE);
    // 分析标准外壳命令、DDE、打开文件操作的命令行
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    // 调度在命令行中指定的命令。如果
    // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
    if (!ProcessShellCommand(cmdInfo))
        return FALSE;
    ////////////////////////////////添加其他视图类
    CView *pOldActiveView=((CFrameWnd*) m_pMainWnd)->GetActiveView();
    CView *pNewActiveView=(CView*)GetDlgItem(AfxGetMainWnd()->m_hWnd,IDD_VIRTUALREPORT);  
    //通过这两行代码可以得到当前的view,并且根据nForm的id值,得到我们的view资源。
    pNewActiveView=(CView*)new CVirtualReport();
    CCreateContext context;
    context.m_pCurrentDoc=pOldActiveView->GetDocument();
    pNewActiveView->Create(NULL,NULL,WS_CHILD | WS_BORDER,CFrameWnd::rectDefault,m_pMainWnd,IDD_VIRTUALREPORT,&context);
    pNewActiveView->OnInitialUpdate();
    // 唯一的一个窗口已初始化,因此显示它并对其进行更新
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();
    // 仅当具有后缀时才调用 DragAcceptFiles
    //  在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生
    // 启用拖/放
    m_pMainWnd->DragAcceptFiles();
     
    //CWnd* LocalIp = GetDlgItem(IDC_EDIT_IP);
    //LocalIp->SetWindowText(m_szServerIP);
    return TRUE;
}
本来好好的 我加入了 连接sql server2008就报错 vs2008

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多