當前位置: 首頁>>代碼示例>>C++>>正文


C++ AfxSocketInit函數代碼示例

本文整理匯總了C++中AfxSocketInit函數的典型用法代碼示例。如果您正苦於以下問題:C++ AfxSocketInit函數的具體用法?C++ AfxSocketInit怎麽用?C++ AfxSocketInit使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AfxSocketInit函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: sizeof

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;
}
開發者ID:inf-eth,項目名稱:i02-0491-courses,代碼行數:60,代碼來源:RadioAndCheckBoxes.cpp

示例2: CreateListener

	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
開發者ID:Decatf,項目名稱:tradelink,代碼行數:35,代碼來源:TLServer_IP.cpp

示例3: InitInstance

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;
}
開發者ID:MatthewChan,項目名稱:Softlumos,代碼行數:60,代碼來源:NetDiskTool.cpp

示例4: InitInstance

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;
}
開發者ID:SherlockLee,項目名稱:KeyBoardWinCE,代碼行數:33,代碼來源:KeyBoardWinCE.cpp

示例5: sizeof

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;
}
開發者ID:KroTozeR,項目名稱:CompNet_Lab3,代碼行數:60,代碼來源:VPing.cpp

示例6: InitInstance

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;
}
開發者ID:BrianAberle,項目名稱:XMLFoundation,代碼行數:32,代碼來源:FilePoster.cpp

示例7: InitInstance

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; 
	}
開發者ID:jordanchuang,項目名稱:geeknimo,代碼行數:31,代碼來源:networks.cpp

示例8: sizeof

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;
}
開發者ID:CN-Zxcv,項目名稱:QService,代碼行數:60,代碼來源:Tool.cpp

示例9: CListenSocket

/*********************************************************
函數名稱: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;
}
開發者ID:yzr0512,項目名稱:ChatServer,代碼行數:35,代碼來源:SocketServerDlg.cpp

示例10: InitCommonControls

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;
}
開發者ID:surf148,項目名稱:SyncNote,代碼行數:60,代碼來源:SyncNote.cpp

示例11: OutputDebugString

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;
}
開發者ID:davidedellai,項目名稱:XFMobile,代碼行數:35,代碼來源:ClientT.cpp

示例12: InitInstance

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;
}
開發者ID:KnowNo,項目名稱:test-code-backup,代碼行數:35,代碼來源:HTTP+Spy.cpp

示例13: InitInstance

BOOL CMMCApp::InitInstance()
{
	CWinApp::InitInstance();

	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	// 將所有 OLE 服務器(工廠)注冊為運行。這將使
	//  OLE 庫得以從其他應用程序創建對象。
	COleObjectFactory::RegisterAll();


	
	//LC_ConnectionOper(1);






	return TRUE;
}
開發者ID:sechacking,項目名稱:r3pos,代碼行數:25,代碼來源:MMC.cpp

示例14: InitInstance

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;
}
開發者ID:wvoice,項目名稱:realtime,代碼行數:34,代碼來源:AVS.cpp

示例15: InitInstance

//--------------------------------------------------------------------------------
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;
	}
開發者ID:richschonthal,項目名稱:Security-Server,代碼行數:30,代碼來源:TokenEditor.cpp


注:本文中的AfxSocketInit函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。