本文整理汇总了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;
}
示例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
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}