BOOL CRadioAndCheckBoxesApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // Create the shell manager, in case the dialog contains // any shell tree view or shell list view controls. CShellManager *pShellManager = new CShellManager; // 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 // 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("Local AppWizard-Generated Applications")); CRadioAndCheckBoxesDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Delete the shell manager created above. if (pShellManager != NULL) { delete pShellManager; } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL TLServer_IP::CreateListener() { if (!AfxSocketInit()) { CString * s = new CString("IDP_SOCKETS_INIT_FAILED"); PostMessage(UWM_INFO, (WPARAM)s, ::GetCurrentThreadId()); return FALSE; } // Create the listener socket UINT portnum = PORT; if(!m_listensoc.Create(portnum)) { /* failed to create */ DWORD err = ::GetLastError(); CString fmt; fmt.LoadString(IDS_LISTEN_CREATE_FAILED); CString * s = new CString; s->Format(fmt, portnum); PostMessage(UWM_INFO, (WPARAM)s, ::GetCurrentThreadId()); PostMessage(UWM_NETWORK_ERROR, (WPARAM)err, ::GetCurrentThreadId()); return FALSE; } /* failed to create */ { /* success */ CString fmt; fmt.LoadString(IDS_LISTENER_CREATED); CString * s = new CString; s->Format(fmt, portnum); PostMessage(UWM_INFO, (WPARAM)s,::GetCurrentThreadId()); } /* success */ m_listensoc.SetTarget(this); m_listensoc.Listen(); return TRUE; } // TLServer_IP::CreateListener
BOOL CNetDiskToolApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } SetUnhandledExceptionFilter(My_UnhandledExceptionFilter); 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("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CNetDiskToolDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CNetDiskToolView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // GetDocumnet()->GetDataType(); return TRUE; }
BOOL CKeyBoardWinCEApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); CKeyBoardWinCEDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此处放置处理何时用“确定”来关闭 // 对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
BOOL CVPingApp::InitInstance() { // InitCommonControlsEx() требуется для Windows XP, если манифест // приложения использует ComCtl32.dll версии 6 или более поздней версии для включения // стилей отображения. В противном случае будет возникать сбой при создании любого окна. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Выберите этот параметр для включения всех общих классов управления, которые необходимо использовать // в вашем приложении. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // Создать диспетчер оболочки, в случае, если диалоговое окно содержит // представление дерева оболочки или какие-либо его элементы управления. CShellManager *pShellManager = new CShellManager; // Стандартная инициализация // Если эти возможности не используются и необходимо уменьшить размер // конечного исполняемого файла, необходимо удалить из следующих // конкретных процедур инициализации, которые не требуются // Измените раздел реестра, в котором хранятся параметры // TODO: следует изменить эту строку на что-нибудь подходящее, // например на название организации SetRegistryKey(_T("Локальные приложения, созданные с помощью мастера приложений")); CVPingDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Введите код для обработки закрытия диалогового окна // с помощью кнопки "ОК" } else if (nResponse == IDCANCEL) { // TODO: Введите код для обработки закрытия диалогового окна // с помощью кнопки "Отмена" } // Удалить диспетчер оболочки, созданный выше. if (pShellManager != NULL) { delete pShellManager; } // Поскольку диалоговое окно закрыто, возвратите значение FALSE, чтобы можно было выйти из // приложения вместо запуска генератора сообщений приложения. return FALSE; }
BOOL CFilePosterApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // Standard initialization #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CFilePosterDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL CNetworksApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); /////////////Êý¾Ý¿â if( (_access( "./user.db", 0 )) == -1 ) { char * pErrMsg = 0; int ret = 0; sqlite3 * db = 0; ret = sqlite3_open("./user.db", &db); if ( ret != SQLITE_OK ) { AfxMessageBox(sqlite3_errmsg(db)); exit(1); } ret = sqlite3_exec(db, "BEGIN TRANSACTION;", NULL, NULL, NULL); sqlite3_exec(db, "CREATE TABLE login(username varchar(64), password varchar(64));", NULL, NULL, NULL); ret = sqlite3_exec(db, "INSERT INTO login VALUES('18d86ccba6c49512154e5abfe51eaa06','d8c993d0e022c4849ac0c27db27ecf69'); \ INSERT INTO login VALUES('5efb93a618588266af575fb8a381d60f','ccf82797241106ef5cbb8c28f2edd63d')", NULL, NULL, &pErrMsg); ret = sqlite3_exec(db, "COMMIT TRANSACTION;", NULL, NULL, NULL); sqlite3_close(db); db = 0; }
BOOL CToolApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 创建 shell 管理器,以防对话框包含 // 任何 shell 树视图控件或 shell 列表视图控件。 CShellManager *pShellManager = new CShellManager; // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); CToolDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 删除上面创建的 shell 管理器。 if (pShellManager != NULL) { delete pShellManager; } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
/********************************************************* 函数名称:OpenServer 功能描述:初始化服务器 作者: 余志荣 创建日期:2016-08-03 返 回 值:成功返回IDS_SERVER_OPEN_SUCCESS *********************************************************/ int CSocketServerDlg::OpenServer(void) { m_pSocketListen = new CListenSocket(this); if(!AfxSocketInit()) {// 套接字初始化失败 OutputInfo(IDP_SOCKETS_INIT_FAILED); // 输出信息 delete m_pSocketListen; // 清除Socket m_pSocketListen = NULL; // 指针置空 return IDP_SOCKETS_INIT_FAILED; } if(m_pSocketListen->Create(8080) == NULL) {// 绑定端口失败 OutputInfo(IDP_SOCKETS_BIND_FAILED); // 输出信息 delete m_pSocketListen; //清除Socket m_pSocketListen = NULL; return IDP_SOCKETS_BIND_FAILED; } m_pSocketListen->Listen(); //启动监听 SetTimer(123, 10000, NULL); // 定时刷新Socket OutputInfo(IDS_SERVER_OPEN_SUCCESS); // 输出信息 return IDS_SERVER_OPEN_SUCCESS; }
BOOL CSyncNoteApp::InitInstance() { // InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. InitCommonControls(); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // 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 // 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("Local AppWizard-Generated Applications")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_SyncNoteTYPE, RUNTIME_CLASS(CSyncNoteDoc), RUNTIME_CLASS(CSyncNoteFrame), // custom MDI child frame RUNTIME_CLASS(CSyncNoteView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; // call DragAcceptFiles only if there's a suffix // In an MDI app, this should occur immediately after setting m_pMainWnd // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line. Will return FALSE if // app was launched with /RegServer, /Register, /Unregserver or /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; // The main window has been initialized, so show and update it pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
BOOL CClientThread::InitInstance() { OutputDebugString(L"CClientThread::InitInstance()\n"); if (!AfxSocketInit()) { return FALSE; } m_socket.Create(); // Try to connect to the peer OutputDebugString(L"Try to connect to the peer"); if (m_socket.Connect(L"206.220.42.147", 25999) == 0) { if (GetLastError() != WSAEWOULDBLOCK) { //error in the connection process, terminate myself OutputDebugString(L"CClientThread::InitInstance() m_socket Failed"); ::PostQuitMessage(0); } } OutputDebugString(L"End CClientThread::InitInstance()"); return TRUE; }
BOOL CHTTPSpyApp::InitInstance() { CHTTPSpyDlg dlg; if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // 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. Enable3dControls(); // Call this when using MFC in a shared DLL m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL CMMCApp::InitInstance() { CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // 将所有 OLE 服务器(工厂)注册为运行。这将使 // OLE 库得以从其他应用程序创建对象。 COleObjectFactory::RegisterAll(); //LC_ConnectionOper(1); return TRUE; }
BOOL CAVSApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif ///////////////////////// // ///////////////////////// CAVSDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } return FALSE; }
//-------------------------------------------------------------------------------- BOOL CTokenEditorApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // 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 CGenRandomTable tbl; CMainDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
// init socket int ctrmthreaddirecttcp::trmsocketinit() { CString t_cs; // 初始化socket if( AfxSocketInit()==FALSE) { assert(0); } // 初始化 CSocket 对象, 因为客户端不需要绑定任何端口和地址, 所以用默认参数即可 if(!m_modeip.Create()) { t_cs.Format(_T("CSocket create faild: %d"),m_modeip.GetLastError()); trmsendtrmdlgcstring(t_cs); return TRUE; } // 连接指定的地址和端口 if(!m_modeip.Connect(m_pitemdata->host,m_pitemdata->port)) { m_modeip.Close(); t_cs=m_pitemdata->host+_T(" Connect FAIL!"); trmsendtrmdlgcstring(t_cs); return TRUE; } return FALSE; }
// // Override InitInstance to create main window. // BOOL CPokerApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDS_SOCKETINITFAILED); return FALSE; } CMainWnd* pMainWnd = new CMainWnd(); m_pMainWnd = pMainWnd; BOOL rc = FALSE; if (pMainWnd) { rc = pMainWnd->Create(NULL, g_szWndClass); } else { rc = FALSE; AfxMessageBox(g_szNotEnoughMemory); } if (rc) rc = Global::Instance().initInstance(); return rc; }
// Starts listening on the specified port. BOOL CNDKServer::StartListening(long lPort) { // Don't call this method two times, call Stop before another // call to StartListening ASSERT(m_pListeningSocket == NULL); BOOL bResult = FALSE; if ((m_pListeningSocket == NULL) && AfxSocketInit()) { m_lPort = lPort; m_pListeningSocket = new CNDKServerSocket(this); if (m_pListeningSocket != NULL) { // Create the socket bResult = m_pListeningSocket->Create(m_lPort); // Start listening if (bResult) bResult = m_pListeningSocket->Listen(); } } // If an error occured destroy the socket if (!bResult && (m_pListeningSocket != NULL)) { delete m_pListeningSocket; m_pListeningSocket = NULL; } return bResult; }
BOOL CClientApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); HANDLE hMutex=::CreateMutex(NULL,TRUE, _T("Remote")); //设置信号量,只允许同一时间只有一个程序运行 if (NULL != hMutex) { if (ERROR_ALREADY_EXISTS == GetLastError()) { MessageBox(NULL,_T("已有一个在程序运行!"), _T("BlackYe远程控制软件"), MB_OK | MB_ICONWARNING); return FALSE; } } CClientDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
BOOL CSnmptreeApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // 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("Mbuf")); // 6-Feb-05 ; load global variable settings int retcode = init_globals(); ASSERT( retcode == 0 ); // LoadStdProfileSettings(6); char *mibdir = netsnmp_get_mib_directory(); /* Fire up the Net-SNMP library */ if( snmpcore_init() != SNMPCORE_SUCCESS ) { // FIXME -- need better error message AfxMessageBox( "Net-SNMP failed to start" ); return FALSE; } mibdir = netsnmp_get_mib_directory(); // To create the main window, this code creates a new frame window // object and then sets it as the application's main window object. CMainFrame* pFrame = new CMainFrame; m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); // The one and only window has been initialized, so show and update it. pFrame->ShowWindow(SW_SHOW); pFrame->UpdateWindow(); return TRUE; }
CDnaCore::CDnaCore() { AfxSocketInit(); m_Loaded = false; Load(); }
CProxyCheck::CProxyCheck(CString ip, CString type, CString port) { AfxSocketInit(); ProxyIpAdd= ip; ProxyType = type; ProxyPort = atol(port.GetBuffer()); }
BOOL COculusApp::InitInstance() { // 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을 // 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다. // InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록 // 이 항목을 설정하십시오. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // 대화 상자에 셸 트리 뷰 또는 // 셸 목록 뷰 컨트롤이 포함되어 있는 경우 셸 관리자를 만듭니다. CShellManager *pShellManager = new CShellManager; // 표준 초기화 // 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면 // 아래에서 필요 없는 특정 초기화 // 루틴을 제거해야 합니다. // 해당 설정이 저장된 레지스트리 키를 변경하십시오. // TODO: 이 문자열을 회사 또는 조직의 이름과 같은 // 적절한 내용으로 수정해야 합니다. SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램")); COculusDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 여기에 [확인]을 클릭하여 대화 상자가 없어질 때 처리할 // 코드를 배치합니다. } else if (nResponse == IDCANCEL) { // TODO: 여기에 [취소]를 클릭하여 대화 상자가 없어질 때 처리할 // 코드를 배치합니다. } // 위에서 만든 셸 관리자를 삭제합니다. if (pShellManager != NULL) { delete pShellManager; } // 대화 상자가 닫혔으므로 응용 프로그램의 메시지 펌프를 시작하지 않고 응용 프로그램을 끝낼 수 있도록 FALSE를 // 반환합니다. return FALSE; }
BOOL CRTX_KinectApp::InitInstance() { CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // Create the shell manager, in case the dialog contains // any shell tree view or shell list view controls. CShellManager *pShellManager = new CShellManager; // Activate "Windows Native" visual manager for enabling themes in MFC controls CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); // 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 // 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("Local AppWizard-Generated Applications")); CRTX_KinectDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } else if (nResponse == -1) { TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n"); TRACE(traceAppMsg, 0, "Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n"); } // Delete the shell manager created above. if (pShellManager != NULL) { delete pShellManager; } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL CInterVALApp::InitInstance() { // Create the VAL object NEWBEGIN g_poVAL = (CVALWin32*) new CVALWin32(); NEWEND("CInterVALApp::InitInstance - VAL object\n"); if (!g_poVAL) return FALSE; if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif SetRegistryKey(_T("vapourtech")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_AVATAR, RUNTIME_CLASS(CDocAvatar), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CViewAvatar)); AddDocTemplate(pDocTemplate); // 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); // Dont open a new MDI window cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; // 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(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; } // InitInstance
BOOL CMainSysApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); #if 1 CMainSysDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; #else CMainSysDlg* pDlg = new CMainSysDlg; pDlg->Create(CMainSysDlg::IDD); pDlg->ShowWindow(SW_HIDE); m_pMainWnd = pDlg; return TRUE; #endif }
BOOL Coc2App::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // 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 // 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("Local AppWizard-Generated Applications")); // To create the main window, this code creates a new frame window // object and then sets it as the application's main window object CMainFrame* pFrame = new CMainFrame; if (!pFrame) return FALSE; m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); // The one and only window has been initialized, so show and update it pFrame->ShowWindow(SW_SHOW); pFrame->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand return TRUE; }
WnetMgr::WnetMgr(void) { mSockInit = AfxSocketInit(); if (XPR_IS_FALSE(mSockInit)) { AfxGetMainWnd()->MessageBox(XPR_STRING_LITERAL("socket creation failed!!!"), XPR_NULL, MB_OK | MB_ICONWARNING); } }
BOOL CRemoteConnectorApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); CRemoteConnectorDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } else if (nResponse == -1) { TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
DWORD CAsyncUrlReader::ThreadProc() { AfxSocketInit(nullptr); DWORD cmd = GetRequest(); if (cmd != CMD_INIT) { Reply((DWORD)E_FAIL); return (DWORD) - 1; } try { CInternetSession is; CAutoPtr<CStdioFile> fin(is.OpenURL(m_url, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_CACHE_WRITE)); TCHAR path[MAX_PATH], fn[MAX_PATH]; CFile fout; if (GetTempPath(MAX_PATH, path) && GetTempFileName(path, _T("mpc_http"), 0, fn) && fout.Open(fn, modeCreate | modeWrite | shareDenyWrite | typeBinary)) { m_fn = fn; char buff[1024]; int len = fin->Read(buff, sizeof(buff)); if (len > 0) { fout.Write(buff, len); } Reply(S_OK); while (!CheckRequest(&cmd)) { int len2 = fin->Read(buff, sizeof(buff)); if (len2 > 0) { fout.Write(buff, len2); } } } else { Reply((DWORD)E_FAIL); } fin->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying } catch (CInternetException* ie) { ie->Delete(); Reply((DWORD)E_FAIL); } // cmd = GetRequest(); ASSERT(cmd == CMD_EXIT); Reply(S_OK); // m_hThread = nullptr; return S_OK; }