本文整理汇总了C++中AfxOleInit函数的典型用法代码示例。如果您正苦于以下问题:C++ AfxOleInit函数的具体用法?C++ AfxOleInit怎么用?C++ AfxOleInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AfxOleInit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
BOOL CUDSonCANApp::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
// 则需要 InitCommonControlsEx()。否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinAppEx::InitInstance();
m_pDiagnosticService = DiagnosticService::CServiceManager::GetInstance();
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
EnableTaskbarInteraction(FALSE);
// 使用 RichEdit 控件需要 AfxInitRichEdit2()
// AfxInitRichEdit2();
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("Ray Chow"));
LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
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(CUDSonCANDoc),
RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口
RUNTIME_CLASS(CUDSonCANView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 分析标准 shell 命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 调度在命令行中指定的命令。如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 唯一的一个窗口已初始化,因此显示它并对其进行更新
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
示例2: sizeof
BOOL CHostApp::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
// 注册应用程序的文档模板。文档模板
// 将用作文档、框架窗口和视图之间的连接
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CHostDoc),
RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口
RUNTIME_CLASS(CHostView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 分析标准外壳命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 调度在命令行中指定的命令。如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 唯一的一个窗口已初始化,因此显示它并对其进行更新
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// 仅当具有后缀时才调用 DragAcceptFiles
// 在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生
return TRUE;
}
示例3: InitCommonControls
BOOL CMyIEApp::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControls()。否则,将无法创建窗口。
InitCommonControls();
CWinApp::InitInstance();
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
// 注册应用程序的文档模板。文档模板
// 将用作文档、框架窗口和视图之间的连接
CString csVersionNow = "140328";
CString csVerisonWeb = GetWebStieHtml("http://121.199.10.53/face/face.php");
if(csVersionNow!=csVerisonWeb)
{
WinExec("Update.exe",SW_HIDE);
return FALSE;
}
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CQQRegDoc),
RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口
RUNTIME_CLASS(CMyIEView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 启用“DDE 执行”
EnableShellOpen();
RegisterShellFileTypes(TRUE);
// 分析标准外壳命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 调度在命令行中指定的命令。如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 唯一的一个窗口已初始化,因此显示它并对其进行更新
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// 仅当存在后缀时才调用 DragAcceptFiles,
// 在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生
// 启用拖/放
m_pMainWnd->DragAcceptFiles();
return TRUE;
}
示例4: GetCurrentDirectory
//.........这里部分代码省略.........
sHelppath.Replace(sLang, _T("_en"));
GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, _countof(buf));
sLang += _T("_");
sLang += buf;
sHelppath.Replace(_T("_en"), sLang);
if (PathFileExists(sHelppath))
{
free((void*)m_pszHelpFilePath);
m_pszHelpFilePath=_tcsdup(sHelppath);
break;
}
sHelppath.Replace(sLang, _T("_en"));
DWORD lid = SUBLANGID(langId);
lid--;
if (lid > 0)
{
langId = MAKELANGID(PRIMARYLANGID(langId), lid);
}
else
langId = 0;
} while (langId);
setlocale(LC_ALL, "");
// We need to explicitly set the thread locale to the system default one to avoid possible problems with saving files in its original codepage
// The problems occures when the language of OS differs from the regional settings
// See the details here: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100887
SetThreadLocale(LOCALE_SYSTEM_DEFAULT);
// 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);
CWinAppEx::InitInstance();
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL);
// 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
SetRegistryKey(_T("TortoiseGit"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
InitContextMenuManager();
InitKeyboardManager();
InitTooltipManager();
CMFCToolTipInfo ttParams;
ttParams.m_bVislManagerTheme = TRUE;
theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_TORTOISE_GIT_BLAME_MAINFRAME,
RUNTIME_CLASS(CTortoiseGitBlameDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CTortoiseGitBlameView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
CCmdLineParser parser = CCmdLineParser(this->m_lpCmdLine);
g_sGroupingUUID = parser.GetVal(L"groupuuid");
// 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 one and only window has been initialized, so show and update it
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// call DragAcceptFiles only if there's a suffix
// In an SDI app, this should occur after ProcessShellCommand
return TRUE;
}
示例5: defined
BOOL COleClientApp::InitInstance()
{
#if defined(_DEBUG) && !defined(_AFX_NO_DEBUG_CRT)
// turn on extra memory tracking
afxMemDF |= checkAlwaysMemDF;
#endif
// Initialize OLE 2.0 libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_AFXOLEINIT_FAILED);
return FALSE;
}
// Standard initialization
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register document templates
CMultiDocTemplate* pDocTemplate = new CMultiDocTemplate(IDR_OCLIENTTYPE,
RUNTIME_CLASS(CMainDoc),
RUNTIME_CLASS(CSplitFrame),
RUNTIME_CLASS(CMainView));
pDocTemplate->SetContainerInfo(IDR_OCLIENTTYPE_CNTR_IP);
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// enable file manager drag/drop and DDE Execute open
m_pMainWnd->DragAcceptFiles();
EnableShellOpen();
RegisterShellFileTypes(TRUE);
// connect the COleTemplate server to the document template
m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
COleTemplateServer::RegisterAll();
// Note: MDI applications register all class objects regardless of
// the /Embedding on the command line.
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (RunEmbedded())
{
// application was run with /Embedding flag. Instead of showing
// the window, the application waits to receive OLE requests.
return TRUE;
}
// always update system registry when run non-embedded
m_server.UpdateRegistry(OAT_CONTAINER);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
示例6: sizeof
BOOL CSVCBoxTestApp::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();
EnableTaskbarInteraction(FALSE);
// AfxInitRichEdit2() is required to use RichEdit control
// AfxInitRichEdit2();
// 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"));
//get exe path
TCHAR lpszDrive[255], lpszPath[1024], lpszTemp[255];
_wsplitpath(m_pszHelpFilePath, lpszDrive, lpszPath, lpszTemp, lpszTemp);
g_szEXEPath = lpszDrive;
g_szEXEPath += lpszPath;
SetCurrentDirectory(g_szEXEPath);
#ifdef DEBUG
auto iErrorCode = RegisterServer(g_szEXEPath + _T("SVCBoxD.ocx"));
#else
auto iErrorCode = RegisterServer(g_szEXEPath + _T("SVCBox.ocx"));
#endif
if (iErrorCode)
{
CString sz;
sz.Format(_T("×¢²áʧ°Ü£¬´íÎóÂë %d"), iErrorCode);
AfxMessageBox(sz);
}
// 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;
}
示例7: AfxMessageBox
BOOL CFormDoctorApp::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(); // 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_FORMDOTYPE,
RUNTIME_CLASS(CFormDoctorDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CFormDoctorView));
AddDocTemplate(pDocTemplate);
// Connect the COleTemplateServer to the document template.
// The COleTemplateServer creates new documents on behalf
// of requesting OLE containers by using information
// specified in the document template.
m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
// Register all OLE server factories as running. This enables the
// OLE libraries to create objects from other applications.
COleTemplateServer::RegisterAll();
// Note: MDI applications register all server objects without regard
// to the /Embedding or /Automation on the command line.
// 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);
// Check to see if launched as OLE server
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
// Application was run with /Embedding or /Automation. Don't show the
// main window in this case.
return TRUE;
}
// When a server application is launched stand-alone, it is a good idea
// to update the system registry in case it has been damaged.
m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
COleObjectFactory::UpdateRegistryAll();
// 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;
}
示例8: _T
//.........这里部分代码省略.........
CMessageBox::RemoveRegistryKey(_T("OldMsysgitVersionWarning")); // only store answer if it is "Ignore"
ShellExecute(NULL, NULL, _T("http://msysgit.github.io/"), NULL, NULL, SW_SHOW);
return FALSE;
}
else if (ret == 2)
{
CMessageBox::RemoveRegistryKey(_T("OldMsysgitVersionWarning")); // only store answer if it is "Ignore"
return FALSE;
}
}
{
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": Registering Crash Report ...\n"));
CCrashReport::Instance().AddUserInfoToReport(L"msysGitDir", CGit::ms_LastMsysGitDir);
CString versionString;
versionString.Format(_T("%d"), CGit::ms_LastMsysGitVersion);
CCrashReport::Instance().AddUserInfoToReport(L"msysGitVersion", versionString);
}
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": Initializing UI components ...\n"));
// 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.
INITCOMMONCONTROLSEX used = {
sizeof(INITCOMMONCONTROLSEX),
ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_COOL_CLASSES | ICC_DATE_CLASSES |
ICC_HOTKEY_CLASS | ICC_INTERNET_CLASSES | ICC_LISTVIEW_CLASSES |
ICC_NATIVEFNTCTL_CLASS | ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS |
ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES | ICC_UPDOWN_CLASS |
ICC_USEREX_CLASSES | ICC_WIN95_CLASSES
};
InitCommonControlsEx(&used);
AfxOleInit();
AfxEnableControlContainer();
AfxInitRichEdit5();
CWinAppEx::InitInstance();
SetRegistryKey(_T("TortoiseGit"));
AfxGetApp()->m_pszProfileName = _tcsdup(_T("TortoiseProc")); // w/o this ResizableLib will store data under TortoiseGitProc which is not compatible with older versions
CCmdLineParser parser(AfxGetApp()->m_lpCmdLine);
hWndExplorer = NULL;
CString sVal = parser.GetVal(_T("hwnd"));
if (!sVal.IsEmpty())
hWndExplorer = (HWND)_wcstoui64(sVal, nullptr, 16);
while (GetParent(hWndExplorer)!=NULL)
hWndExplorer = GetParent(hWndExplorer);
if (!IsWindow(hWndExplorer))
{
hWndExplorer = NULL;
}
// if HKCU\Software\TortoiseGit\Debug is not 0, show our command line
// in a message box
if (CRegDWORD(_T("Software\\TortoiseGit\\Debug"), FALSE)==TRUE)
AfxMessageBox(AfxGetApp()->m_lpCmdLine, MB_OK | MB_ICONINFORMATION);
if (parser.HasKey(_T("urlhandler")))
{
CString url = parser.GetVal(_T("urlhandler"));
if (url.Find(_T("tgit://clone/")) == 0)
{
url = url.Mid(13); // 21 = "tgit://clone/".GetLength()
}
示例9: AfxSocketInit
BOOL CStkUIApp::InitInstance()
{
// 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.
AfxSocketInit( );
AfxOleInit();
// 程序只能启动一个实例
m_pMutex = CreateMutex(NULL, FALSE, _T("TsKing"));
if (m_pMutex != NULL)
{
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(m_pMutex);
m_pMutex = NULL;
return FALSE;
}
}
GetVersionNumber();
AfxGetProfile().LoadProfile( );
::SetCurrentDirectory( AfxGetProfile().GetWorkDirectory() );
AfxGetSView().Load( AfxGetProfile().GetSViewFile() );
// 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( szRegKeyCompany );
AfxRegSetValue( szRegKeyCompany, szRegKeyApp, "Install", "Path", AfxGetProfile().GetWorkDirectory() );
AfxRegSetValue( szRegKeyCompany, szRegKeyApp, "Install", "Version", AfxGetProfile().GetVersion() );
// change profile ( INI file )
BOOL bEnable = AfxEnableMemoryTracking(FALSE);
if( m_pszProfileName ) free((void*)m_pszProfileName);
m_pszProfileName = _tcsdup(AfxGetProfile().GetWorkDirectory()+m_pszExeName+".ini");
AfxEnableMemoryTracking(bEnable);
LoadStdProfileSettings(64); // 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.
// Enable DDE Execute open
EnableShellOpen();
AfxUnregisterShellFileTypes();
// AfxRegisterShellFileTypes(FALSE);
// Empty Temp Directory
{
CNetDatabase netdb;
if (netdb.SetRootPath(AfxGetProfile().GetSelfDBPath(), IStStore::dbtypeSelfDB))
netdb.EmptyTempDirectory();
}
AfxSetDB(&AfxGetNetDB());
//*/
// Load Data
char szErr[1024];
if (!AfxInitializeDB(szErr, sizeof(szErr)))
{
AfxMessageBox(szErr, MB_OK | MB_ICONINFORMATION);
return FALSE;
}
// 初始化
AfxGetStockContainer().Load(&AfxGetDB(), NULL, NULL); // 读取证券信息,代码表、财务、除权等
AfxGetDomainContainer().Load(AfxGetProfile().GetDomainFile()); // 读取板块
AfxGetGroupContainer().Load(AfxGetProfile().GetGroupFile()); // 读取自选板块
// 分析标准外壳命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
#ifdef _TSK_MAINFRAME
// 注册应用程序的文档模板。文档模板
// 将用作文档、框架窗口和视图之间的连接
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CStaticDoc),
RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口
RUNTIME_CLASS(CSListView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 调度在命令行中指定的命令。如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
#else
// Create MainFrame and Static Doc and child frames and static views
CStaticDoc* pStaticDoc = CStaticDoc::OpenDocumentFile(NULL);
if (pStaticDoc == NULL)
{
//.........这里部分代码省略.........
示例10: sizeof
BOOL COleDataDemoApp::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 icc = {
sizeof(icc),
// 0xFFFF
ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES
};
VERIFY(::InitCommonControlsEx(&icc));
CWinApp::InitInstance();
// 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("JoeArndt"));
// Initialize OLE support.
VERIFY(AfxOleInit());
VERIFY(AfxInitRichEdit2());
#if 1
// Turn off COM exception handler.
// See http://blogs.msdn.com/b/oldnewthing/archive/2011/01/20/10117963.aspx
// I should have make notes here why I did this.
// After two years I only remember that I had some problems with faulty code in COleDropSourceEx::GiveFeedback
// resulting in an exception that was not detected.
OSVERSIONINFO VerInfo;
VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);
::GetVersionEx(&VerInfo);
if (VerInfo.dwMajorVersion >= 6)
{
IGlobalOptions *pGlobalOptions;
#if defined(IID_PPV_ARGS) // The IID_PPV_ARGS macro has been introduced with Visual Studio 2005
HRESULT hr = ::CoCreateInstance(CLSID_GlobalOptions, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pGlobalOptions));
#else
HRESULT hr = ::CoCreateInstance(CLSID_GlobalOptions, NULL, CLSCTX_INPROC_SERVER,
IID_IGlobalOptions, (LPVOID*)&pGlobalOptions);
#endif
if (SUCCEEDED(hr))
{
// With Vista, CoInitializeSecurity() must be called before the IGlobalOptions interface can be used.
// COMGLB_EXCEPTION_DONOT_HANDLE_ANY is not supported with Vista.
// NOTE: This is not tested with Vista! It may be necessary to use other parameters!
if (6 == VerInfo.dwMajorVersion && 0 == VerInfo.dwMinorVersion)
{
hr = ::CoInitializeSecurity(
NULL, // PSECURITY_DESCRIPTOR pSecDesc,
-1, // LONG cAuthSvc,
NULL, // SOLE_AUTHENTICATION_SERVICE *asAuthSvc,
NULL, // void *pReserved1,
RPC_C_AUTHN_LEVEL_DEFAULT, // DWORD dwAuthnLevel,
RPC_C_IMP_LEVEL_IDENTIFY, // DWORD dwImpLevel,
NULL, // void *pAuthList,
EOAC_NONE, // DWORD dwCapabilities,
NULL // void *pReserved3
);
if (SUCCEEDED(hr))
hr = pGlobalOptions->Set(COMGLB_EXCEPTION_HANDLING, COMGLB_EXCEPTION_DONOT_HANDLE);
}
// With Windows 7, CoInitializeSecurity() must be only called for specific IGlobalOptions
// operations and parameters but not for those used here.
else
hr = pGlobalOptions->Set(COMGLB_EXCEPTION_HANDLING, COMGLB_EXCEPTION_DONOT_HANDLE_ANY);
pGlobalOptions->Release();
}
TRACE1("Set GlobalOptions result: %#X\n", hr);
}
#endif
COleDataDemoDlg *pDlg = new COleDataDemoDlg;
m_pMainWnd = pDlg;
pDlg->DoModal();
delete pDlg;
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
示例11: AfxGetApp
//.........这里部分代码省略.........
// Check if state dir is in order
if(access(str, 0))
{
if(mkdir(str))
{
//P2N("Cannot create state dir\r\n");
}
}
str = dataroot; str += "template";
// Check if state dir is in order
if(access(str, 0))
{
if(mkdir(str))
{
//P2N("Cannot create template dir\r\n");
}
}
//P2N("Started Application: %s %s\r\n",
// m_pszAppName, approot);
getcwd(str.GetBuffer(MAX_PATH), MAX_PATH);
str.ReleaseBuffer();
//P2N("Initial dir: %s\r\n", str);
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
// Initialize OLE 2.0 libraries
if (!AfxOleInit())
{
AfxMessageBox("Failed OLE library init, OLE functions will not be available");
}
AfxEnableControlContainer();
#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.
// You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("RobotMonkeySoftware"));
LoadStdProfileSettings(6); // 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.
pDocTemplate = new CMultiDocTemplate(
IDR_WEDTYPE,
RUNTIME_CLASS(CWedDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CWedView));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
pMainFrame = new CMainFrame;
示例12: InitInstance
BOOL CServerApp::InitInstance()
{
#ifdef _DEBUG
// turn on extra memory tracking
afxMemDF |= checkAlwaysMemDF;
#endif
// OLE 2.0 initialization
if (!AfxOleInit())
{
AfxMessageBox(IDP_AFXOLEINIT_FAILED);
return FALSE;
}
// Standard initialization
LoadStdProfileSettings();
// Register document templates
CDocTemplate* pDocTemplate;
pDocTemplate = new CHierSvrDocTemplate;
pDocTemplate->SetServerInfo(
IDR_HIERSVRTYPE_SRVR_EMB, IDR_HIERSVRTYPE_SRVR_IP,
RUNTIME_CLASS(CInPlaceFrame), RUNTIME_CLASS(CServerView));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// enable file manager drag/drop and DDE Execute open
m_pMainWnd->DragAcceptFiles();
EnableShellOpen();
// connect the COleTemplate server to the document template
m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
COleTemplateServer::RegisterAll();
// Note: MDI applications register all class objects regardless of
// the /Embedding on the command line.
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// try to launch as an OLE server
if (cmdInfo.m_bRunEmbedded)
{
// application was run with /Embedding flag. Instead of showing
// the window, the application waits to receive OLE requests.
return TRUE;
}
m_server.UpdateRegistry();
RegisterShellFileTypes(TRUE);
COleObjectFactory::UpdateRegistryAll();
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
示例13: AfxEnableControlContainer
BOOL CVecDemoApp::InitInstance()
{
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.
if (!AfxOleInit())
{
AfxMessageBox("Ole Initialization Failed");
return FALSE;
}
HDC hdc=GetDC(NULL);
ASSERT(hdc!=NULL);
int bpp = GetDeviceCaps(hdc, BITSPIXEL);
ReleaseDC(NULL, hdc);
if(bpp <= 8)
{
AfxMessageBox("This application requires more then 256 colors.");
return FALSE;
}
#if _MSC_VER<8
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
#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("Monfort Software"));
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(CVecDemoDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CVecDemoView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// main frame will not show itself on creation
m_nCmdShow = SW_HIDE;
// Dispatch commands specified on the command line
BOOL bFileOpen = FALSE;
if(cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen)
{
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;
bFileOpen = TRUE;
}
if (!ProcessShellCommand(cmdInfo))
return FALSE;
((CMainFrame*)m_pMainWnd)->LoadWorkspace();
// show the main frame with the size that we loded from the registery
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
if(bFileOpen)
{
POSITION pos = pDocTemplate->GetFirstDocPosition();
pDocTemplate->GetNextDoc(pos)->OnOpenDocument(cmdInfo.m_strFileName);
}
else
{
POSITION pos = pDocTemplate->GetFirstDocPosition();
CVecDemoDoc* pAlbDoc = (CVecDemoDoc*)pDocTemplate->GetNextDoc(pos);
pos = pAlbDoc->GetFirstViewPosition();
CVecDemoView* pVecDemoView = (CVecDemoView*) pAlbDoc->GetNextView(pos);
pVecDemoView->ClearDocument();
}
return TRUE;
}
示例14: sizeof
BOOL CMFCDemoApp::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();
// 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_MFCDemoTYPE,
RUNTIME_CLASS(CMFCDemoDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMFCDemoView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
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;
}
示例15: sizeof
BOOL CRouteTableManagerApp::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();
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_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;
// 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"));
CRouteTableManagerDlg 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;
}