// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
    // registers object, typelib and all interfaces in typelib
	HRESULT  hr;    // return for safety functions

	AFX_MANAGE_STATE(AfxGetStaticModuleState());

    if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid)) 
        return ResultFromScode(SELFREG_E_TYPELIB);

    if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
        return ResultFromScode(SELFREG_E_CLASS);

    // Mark the control as safe for initializing.

    hr = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data!");
    if (FAILED(hr))
        return hr;
	
    hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForInitializing);
    if (FAILED(hr))
        return hr;

    // Mark the control as safe for scripting.

    hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls safely scriptable!");
    if (FAILED(hr))
        return hr;

    hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForScripting);
    if (FAILED(hr))
        return hr;

    return NOERROR;
}
// Sie können regsvr.exe verwenden, indem Sie DllRegisterServer exportieren
STDAPI DllRegisterServer(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	COleObjectFactory::UpdateRegistryAll();
	VERIFY(AfxOleRegisterTypeLib(AfxGetInstanceHandle(), theTypeLibGUID, "ExchangeData"));
	return S_OK;
}
示例#3
0
STDAPI DllRegisterServer(void)
{
	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
		return ResultFromScode(SELFREG_E_TYPELIB);

	if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
		return ResultFromScode(SELFREG_E_CLASS);
    //创建脚本安全“补充”项,非CLSID中  
    HRESULT hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls safely scriptable!");  
    if (FAILED(hr))  
        return hr;  
  
    //创建初始化安全“补充”项,非CLSID中  
    hr = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data!");  
    if (FAILED(hr))  
        return hr;  
  
    //设置控件CLSID中补充项的脚本安全项,与“补充”项中的脚本安全项对应  
    hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForScripting);  
    if (FAILED(hr))  
        return hr;  
  
    //设置控件CLSID中补充项的初始化安全项,与“补充”项中的初始化安全项对应  
    hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForInitializing);  
    if (FAILED(hr))  
        return hr;  
	return NOERROR;
}
/**
 Function : STDAPI DllRegisterServer(void)
 Purpose  : Adds entries to the system registry.
 Version  : 1.0.0
*/
STDAPI DllRegisterServer(void) {
	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid)) return ResultFromScode(SELFREG_E_TYPELIB);

	if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE)) return ResultFromScode(SELFREG_E_CLASS);

	return NOERROR;
}
示例#5
0
STDAPI DllRegisterServer(void)
{
    AFX_MANAGE_STATE(_afxModuleAddrThis);

    if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
        return ResultFromScode(SELFREG_E_TYPELIB);

    if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), LIBID_blaxxunVRMLLib, "blaxxunVRML.tlb")) {
//#ifdef _DEBUG
        MessageBox(NULL,"Can´t register blaxxunVRML.tlb type library\nEAI may not work",_PROGRAM,MB_OK);
        //	return ResultFromScode(SELFREG_E_TYPELIB);
//#endif
    }



    if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
        return ResultFromScode(SELFREG_E_CLASS);

    return NOERROR;
}
示例#6
0
文件: MMC.cpp 项目: sechacking/r3pos
STDAPI DllRegisterServer(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
		return SELFREG_E_TYPELIB;

	if (!COleObjectFactory::UpdateRegistryAll())
		return SELFREG_E_CLASS;

	return S_OK;
}
示例#7
0
STDAPI DllRegisterServer(void)
{
	HRESULT hr;

	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
	{
		return ResultFromScode(SELFREG_E_TYPELIB);//lint !e835
	}

	if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
	{
		return ResultFromScode(SELFREG_E_CLASS);
	}
	hr = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data!");  //lint !e1776  MFC自动生成的的函数
	if (FAILED(hr))
	{
		return hr;
	}
	hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForInitializing); 
	if (FAILED(hr))      
	{
		return hr;   
	}
	hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls safely  scriptable!");   //lint !e1776  MFC自动生成的的函数
	if (FAILED(hr))
	{
		return hr;   
	}
	hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForScripting);  
	if (FAILED(hr))     
	{
		return hr;    
	}
	return NOERROR;
}//lint !e1788
示例#8
0
文件: XiYuan.cpp 项目: mba811/XiYuan
BOOL CXiYuanApp::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;
	}

	// 初始化 OLE 库
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	EnableTaskbarInteraction();

	// 使用 RichEdit 控件需要  AfxInitRichEdit2()	
	// AfxInitRichEdit2();

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO:  应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
	LoadStdProfileSettings(16);  // 加载标准 INI 文件选项(包括 MRU)

	// GDI+
	GdiplusStartupInput gdiplusStartupInput;
	GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);

	InitContextMenuManager();

	InitKeyboardManager();

	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

	// 注册应用程序的文档模板。  文档模板
	// 将用作文档、框架窗口和视图之间的连接
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(IDR_XiYuanTYPE,
		RUNTIME_CLASS(CXiYuanDoc),
		RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架
		RUNTIME_CLASS(CXiYuanView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);
	// 将 COleTemplateServer 连接到文档模板
	// COleTemplateServer 通过使用
	// 文档模板中指定的信息来为请求 OLE 容器
	// 创建新文档
	m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
	// 将所有的 OLE 服务器工厂注册为正在运行。  这将启用
	//  OLE 库以从其他应用程序中创建对象
	COleTemplateServer::RegisterAll();
		// 注意:  MDI 应用程序将注册所有的服务器对象,而不管
		// 命令行上的 /Embedding 或 /Automation

	// 创建主 MDI 框架窗口
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		delete pMainFrame;
		return FALSE;
	}
	m_pMainWnd = pMainFrame;


	// 分析标准 shell 命令、DDE、打开文件操作的命令行
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);


	// 应用程序是用 /Embedding 或 /Automation 开关启动的。
	//使应用程序作为自动化服务器运行。
	if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
	{
		// 不显示主窗口
		return TRUE;
	}
	// 使用 /Unregserver 或 /Unregister 开关启动应用程序。  注销
	// 类型库。  其他注销操作在 ProcessShellCommand() 中发生。
	else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
	{
		m_server.UpdateRegistry(OAT_DISPATCH_OBJECT, NULL, NULL, FALSE);
		AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
	}
	// 应用程序是以独立方式或用其他开关(如 /Register
	// 或 /Regserver)启动的。  更新注册表项,包括类型库。
	else
	{
		m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
		COleObjectFactory::UpdateRegistryAll();
		AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
	}

	// 调度在命令行中指定的命令。  如果
	// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// 主窗口已初始化,因此显示它并对其进行更新
	pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
	pMainFrame->UpdateWindow();

	return TRUE;
}
示例#9
0
文件: test2.cpp 项目: galaft/test2
BOOL Ctest2App::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;
	}


	// 初始化 OLE 库
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	// 创建 shell 管理器,以防对话框包含
	// 任何 shell 树视图控件或 shell 列表视图控件。
	CShellManager *pShellManager = new CShellManager;

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
	// 分析自动化开关或注册/注销开关的命令行。
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// 应用程序是用 /Embedding 或 /Automation 开关启动的。
	//使应用程序作为自动化服务器运行。
	if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
	{
		// 通过 CoRegisterClassObject() 注册类工厂。
		COleTemplateServer::RegisterAll();
	}
	// 应用程序是用 /Unregserver 或 /Unregister 开关启动的。移除
	// 注册表中的项。
	else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
	{
		COleObjectFactory::UpdateRegistryAll(FALSE);
		AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
		return FALSE;
	}
	// 应用程序是以独立方式或用其他开关(如 /Register
	// 或 /Regserver)启动的。更新注册表项,包括类型库。
	else
	{
		COleObjectFactory::UpdateRegistryAll();
		AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
		if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister)
			return FALSE;
	}

	Ctest2Dlg 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;
}
示例#10
0
BOOL CCANMonitorApp::InitInstance()
{
    // Begin of Multiple Language support
    if ( CMultiLanguage::m_nLocales <= 0 )    // Not detected yet
    {
        CMultiLanguage::DetectLangID(); // Detect language as user locale
        CMultiLanguage::DetectUILanguage();    // Detect language in MUI OS
    }
    TCHAR szModuleFileName[MAX_PATH];        // Get Module File Name and path
    int ret = ::GetModuleFileName(theApp.m_hInstance, szModuleFileName, MAX_PATH);
    if ( ret == 0 || ret == MAX_PATH )
    {
        ASSERT(false);
    }
    // Load resource-only language DLL. It will use the languages
    // detected above, take first available language,
    // or you can specify another language as second parameter to
    // LoadLangResourceDLL. And try that first.
    ghLangInst = CMultiLanguage::LoadLangResourceDLL( szModuleFileName );
    if (ghLangInst)
    {
        AfxSetResourceHandle( ghLangInst );
    }
    // End of Multiple Language support

	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

    //InitCommonControls();
    // START CHANGES MADE FOR AUTOMATION
	CWinAppEx::InitInstance();

    // Initialize OLE libraries
    if (!AfxOleInit())
    {
        AfxMessageBox(_("Fail to Intilaize OLE"));
        return FALSE;
    }
    //CoInitializeEx(nullptr, COINIT_MULTITHREADED );

    CBusmasterDump dump("BUSMASTER");
    // END CHANGES MADE FOR AUTOMATION
    // Enable OLE/ActiveX objects support
    AfxEnableControlContainer();
	InitContextMenuManager();
	InitKeyboardManager();
	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
    // 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. DEBUG
//#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("RBEI-ETAS\\BUSMASTER_v3.1.0");
    // START CHANGES MADE FOR AUTOMATION
    COleTemplateServer::RegisterAll();
    // END CHANGES MADE FOR AUTOMATION
    //LoadStdProfileSettings(0); // Load standard INI file options (including MRU)
    // Enable drag/drop open
    // Enable DDE Execute open
    //EnableShellOpen();
    //RegisterShellFileTypes(TRUE);
    // Display splash screen
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    short shRegServer = -1;
    short shUnRegServer = -1;

    if (__argc > 1)
    {
        shRegServer = (short) strcmpi(__targv[1],"/regserver");
        shUnRegServer = (short) strcmpi(__targv[1],"/unregserver");
    }

    // Don't display a new MDI child window during startup
    if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew
            || cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen)
    {
        cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
    }

    // START CHANGES MADE FOR AUTOMATION

    if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
    {
        m_bFromAutomation = TRUE;
        //      return TRUE;
    }
    else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
    {
        AfxOleUnregisterTypeLib(LIBID_CAN_MonitorApp);
    }
    else
    {
        COleObjectFactory::UpdateRegistryAll();
        AfxOleRegisterTypeLib(AfxGetInstanceHandle(), LIBID_CAN_MonitorApp);
    }

    if (  shRegServer == 0  || shUnRegServer == 0 ) //If command line argument match
    {
        return FALSE;
    }

    if (!m_bFromAutomation)
    {
        CSplashScreen::ActivateSplashScreen(cmdInfo.m_bShowSplash);
    }

    // Allocate memory for CFlags
    m_pouFlags = &(CFlags::ouGetFlagObj());
    // create main MDI Frame window
    CMainFrame* pMainFrame = new CMainFrame;

    if ( pMainFrame == nullptr )
    {
        ::PostQuitMessage(0);
        return FALSE;
    }

    if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    {
        return FALSE;
    }

    m_pMainWnd = pMainFrame;

    // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    {
        return FALSE;
    }

    m_pMainWnd->DragAcceptFiles();
    // show main frame
    m_pMainWnd->ShowWindow(m_nCmdShow);
    m_pMainWnd->UpdateWindow();
    //// Create message window



    if(m_pouMsgSgInactive == nullptr )
    {
        if(m_bFromAutomation==FALSE)
            MessageBox(nullptr,_(MSG_MEMORY_CONSTRAINT),
                       "BUSMASTER", MB_OK|MB_ICONINFORMATION);

        ::PostQuitMessage(0);
    }

    BOOL bResult;
    bResult = m_aomState[UI_THREAD].SetEvent();
    // get the information of the last used configuration file..
    // initialize the flag that indicates if the configuratin file has been
    // loaded..
    m_bIsConfigFileLoaded = FALSE;
    CString ostrCfgFilename = "";

    // If user has double click the .cfg file then assign that file name else
    // read from registry.
    if(cmdInfo.m_strFileName.IsEmpty() == TRUE)
    {
        //ostrCfgFilename =
        //    GetProfileString(_(SECTION), defCONFIGFILENAME, "");
        DWORD dwVal;
        bReadFromRegistry(HKEY_CURRENT_USER, _(SECTION), defCONFIGFILENAME, REG_SZ, ostrCfgFilename, dwVal);
    }
    else
    {
        ostrCfgFilename = cmdInfo.m_strFileName;
    }

    BOOL bValidDir = TRUE;
    CFileFind findFile;
    if (!ostrCfgFilename.IsEmpty() && !findFile.FindFile(ostrCfgFilename))
    {
        DWORD dwErr = GetLastError();
        CString strMsg = "";
        if (dwErr == ERROR_PATH_NOT_FOUND)
        {
            bValidDir = FALSE;
            FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, dwErr, 0, strMsg.GetBuffer(1024), 1024, nullptr);
            AfxMessageBox(strMsg);
        }
    }
    if(ostrCfgFilename.IsEmpty() == FALSE && bValidDir == TRUE)
    {
        bInitialiseConfiguration(m_bFromAutomation);

        // load the configuration information
        if(pMainFrame->nLoadConfigFile(ostrCfgFilename) != defCONFIG_FILE_SUCCESS)
        {
            //m_oConfigDetails.vInitDefaultValues();
            m_ostrConfigFilename = "";
        }
        else
        {
            m_ostrConfigFilename = ostrCfgFilename;
        }

        m_bIsConfigFileLoaded = TRUE;

        //build all nodes -- Node Simulation.
        pMainFrame->BuildAllNodes();

    }
    else
    {
        BOOL bReturn = bInitialiseConfiguration(m_bFromAutomation);

        if(bReturn == FALSE )
        {
            ::PostQuitMessage(0);
        }

        // Load a default database file
        //CStringArray omDatabaseArray;
        //CString omSampleDatabasePath;
        //omSampleDatabasePath.Format("%s\\Samples\\SampleDB.dbf",m_acApplicationDirectory);
        //DWORD dRetVal = pMainFrame->dLoadDataBaseFile(omSampleDatabasePath, FALSE);

        //if (dRetVal == S_OK)
        //{
        //    //omDatabaseArray.Add(omSampleDatabasePath);
        //    //Store in configdetails
        //    //bSetData(DATABASE_FILE_NAME, &omDatabaseArray);
        //    bWriteIntoTraceWnd(_(MSG_DEFAULT_DATABASE));
        //    bWriteIntoTraceWnd(_(MSG_CREATE_UNLOAD_DATABASE));
        //}
        pMainFrame->OnHex_DecButon();           // setting HEX by default
    }

    // ********  Filter workaround  ********
    // Filter list is initialised before msg wnd creation. So update display
    // filter here
    // Update Message Display Filter List
    //::PostThreadMessage(GUI_dwThread_MsgDisp, TM_UPDATE_FILTERLIST, nullptr, nullptr );
    // ********  Filter workaround  ********

    // Start Logging if is enabled
    // Get the Flag Pointer
    CFlags* pomFlag =  pouGetFlagsPtr();

    if( pomFlag != nullptr )
    {
        // Get the Logging Status
        BOOL bLogON = pomFlag->nGetFlagStatus(LOGTOFILE);

        // If it is on then post a message to display thread to start logging
        if(bLogON == TRUE )
        {
            // Start Logging
            //CLogManager::ouGetLogManager().vStartStopLogging( TRUE );
        }
    }
    //pMainFrame->OnHex_DecButon();           // setting HEX by default
    //CExecuteManager::ouGetExecuteManager().vStartDllReadThread();
    return TRUE;
}
示例#11
0
// CALApp initialization
BOOL CALApp::InitInstance()
{
    // this call will popup onother instance if is running
    if (g_SingleInstanceObj.IsAnotherInstanceRunning())
    {
        return FALSE;
    }

    // Register and exit if it fails
    if (!g_SingleInstanceObj.RegisterInstance())
    {
        TRACE("Class Registration Failed\n");
        return FALSE;
    }

    // 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("ActiveLog"));

    // DO WE HAVE THIS ???
    //LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
    //If nMaxMRU is 0, no MRU list will be maintained.
    LoadStdProfileSettings(0);

    WINDOWPLACEMENT wp;
    if (ReadWindowPlacement(&wp))
    {
        if (wp.flags & WPF_RESTORETOMAXIMIZED)
            m_nCmdShow = SW_SHOWMAXIMIZED;
    }

    // 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(CALDoc),
        RUNTIME_CLASS(CMainFrame),       // main SDI frame window
        RUNTIME_CLASS(CLeftView));
    if (!pDocTemplate)
        return FALSE;
    AddDocTemplate(pDocTemplate);

    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);

    // http://support.microsoft.com/kb/q129095/
    // info about reg type and names

    // App was launched with /Embedding or /Automation switch.
    // Run app as automation server.
    if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
    {
        // Register all OLE server factories as running.  This enables the
        //  OLE libraries to create objects from other applications
        COleTemplateServer::RegisterAll();

        // WORKAROUND - TO INITIALIZE DOC-VIEW
        // Don't show the main window
        //return TRUE;
    }
    // App was launched with /Unregserver or /Unregister switch.  Unregister
    // typelibrary.  Other unregistration occurs in ProcessShellCommand().
    else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
    {
        //FALSE results in unregistering all COM objects implemented as
        //CCmdTarget derived classes.
        COleObjectFactory::UpdateRegistryAll(FALSE);
        AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
    }
    // App was launched standalone or with other switches (e.g. /Register
    // or /Regserver).  Update registry entries, including typelibrary.
    else
    {
        COleObjectFactory::UpdateRegistryAll();
        // Register all OLE server factories as running.  This enables the
        //  OLE libraries to create objects from other applications
        COleTemplateServer::RegisterAll();
        AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
    }

    // warning C6214: Cast between semantically different integer types: HRESULT to a Boolean type
    // move this to setup application ???

    // v.0.09.02 - fix for Vista
    // do not exit application, this job has been moved to installation
    RegisterSafeScripting();

    // 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;
}
示例#12
0
文件: tbedit.cpp 项目: DeegC/10d
STDAPI DllRegisterServer(void)
{
   AFX_MANAGE_STATE(_afxModuleAddrThis);

   TBRegistry * pReg = new TBRegistry( REGISTRYKEY, (unsigned long)HKEY_CURRENT_USER );

   if( pReg->CreateKey() )
   {
      DWORD dTyp;
      DWORD dSize;
      DWORD dWert;
      CString strFont = "Courier";
      LPSTR lpszFont = NULL;
      COLORREF cr;

      //Schriftart -> Arial
      strFont = "Courier";
      dSize = strFont.GetLength() + 1;
      lpszFont = strFont.GetBufferSetLength( MAX_PATH + 1 );
      dSize = MAX_PATH;

      if( !pReg->ReadValue( REGFONT, &dTyp, (LPBYTE)lpszFont, &dSize ) )
      {
         strFont.ReleaseBuffer();
         strFont = "Courier";
         dTyp = REG_SZ;
         dSize = strFont.GetLength() + 1;
         pReg->WriteValue( REGFONT, dTyp, (LPBYTE)(LPCSTR)strFont, dSize );
      }

      //Schriftgroesse -> 9
      dTyp = REG_DWORD;
      dSize = zsizeof ( dWert );
      dWert = 180;
      if ( !pReg->ReadValue( REGSIZE, &dTyp, (LPBYTE)&dWert, &dSize ) )
      {
         dWert = 180;
         dTyp = REG_DWORD;
         dSize = zsizeof ( dWert );
         pReg->WriteValue( REGSIZE, dTyp, (LPBYTE)&dWert, dSize );
      }

      //Hintergrundfarbe -> Weiß
      dTyp = REG_DWORD;
      dSize = zsizeof ( cr );
      if ( !pReg->ReadValue( REGBACK, &dTyp, (LPBYTE)&cr, &dSize ) )
      {
         dTyp = REG_DWORD;
         dSize = zsizeof ( cr );
         cr = RGB( 255, 255, 255 );
         pReg->WriteValue( REGBACK, dTyp, (LPBYTE)&cr, dSize );
      }

      //Vordergrund -> Schwarz
      dTyp = REG_DWORD;
      dSize = zsizeof ( cr );
      if ( !pReg->ReadValue( REGFORE, &dTyp, (LPBYTE)&cr, &dSize ) )
      {
         dTyp = REG_DWORD;
         dSize = zsizeof ( cr );
         cr = RGB( 0,0,0 );
         pReg->WriteValue( REGFORE, dTyp, (LPBYTE)&cr, dSize );
      }

      //KeywordFarbe -> Rot
      dTyp = REG_DWORD;
      dSize = zsizeof ( cr );
      if ( !pReg->ReadValue( REGWORD, &dTyp, (LPBYTE)&cr, &dSize ) )
      {
         dTyp = REG_DWORD;
         dSize = zsizeof ( cr );
         cr = RGB( 255, 0, 0 );
         pReg->WriteValue( REGWORD, dTyp, (LPBYTE)&cr, dSize );
      }

      //Kommentarfarbe -> Blau
      dTyp = REG_DWORD;
      dSize = zsizeof ( cr );
      if ( !pReg->ReadValue( REGCOMMENT, &dTyp, (LPBYTE)&cr, &dSize ) )
      {
         dTyp = REG_DWORD;
         dSize = zsizeof ( cr );
         cr = RGB( 0, 0, 255 );
         pReg->WriteValue( REGCOMMENT, dTyp, (LPBYTE)&cr, dSize );
      }

      //Tabstop-Weite -> 4
      dTyp = REG_DWORD;
      dSize = zsizeof ( dWert );
      if ( !pReg->ReadValue( REGTABSTOP, &dTyp, (LPBYTE)&dWert, &dSize ) )
      {
         dTyp = REG_DWORD;
         dWert = 4;
         pReg->WriteValue( REGTABSTOP, dTyp, (BYTE*)&dWert, dSize );
      }

      //UndoLevel -> 30
      dTyp = REG_DWORD;
      dSize = zsizeof ( dWert );
      if ( !pReg->ReadValue( REGUNDOLEVEL, &dTyp, (LPBYTE)&dWert, &dSize ) )
      {
         dTyp = REG_DWORD;
         dWert = 30;
         pReg->WriteValue( REGUNDOLEVEL, dTyp, (BYTE*)&dWert, dSize );
      }

      //Anzahl Zeilen fuer Kommentarpuffer -> 100
      dTyp = REG_DWORD;
      dSize = zsizeof ( dWert );
      if ( !pReg->ReadValue( REGBUFFERSIZE, &dTyp, (LPBYTE)&dWert, &dSize ) )
      {
         dTyp = REG_DWORD;
         dWert = 100;
         pReg->WriteValue( REGBUFFERSIZE, dTyp, (BYTE*)&dWert, dSize );
      }
   }

   delete pReg;

   if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
   return ResultFromScode(SELFREG_E_TYPELIB);

   if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
   return ResultFromScode(SELFREG_E_CLASS);

   return NOERROR;
}
BOOL CSpeechApp::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);

	CWinAppEx::InitInstance();


	// 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("Packt Publishing\\Ogre3D Cookbook\\Speech Ogre Application"));
	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_MAINFRAME,
		RUNTIME_CLASS(CSpeechDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CSpeechView));
	if (!pDocTemplate)
		return FALSE;
	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, TRUE);
		// Note: SDI applications register server objects only if /Embedding
		//   or /Automation is present on the command line


	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

	// App was launched with /Embedding or /Automation switch.
	// Run app as automation server.
	if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
	{
		// Register all OLE server factories as running.  This enables the
		//  OLE libraries to create objects from other applications
		COleTemplateServer::RegisterAll();

		// Don't show the main window
		return TRUE;
	}
	// App was launched with /Unregserver or /Unregister switch.  Unregister
	// typelibrary.  Other unregistration occurs in ProcessShellCommand().
	else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
	{
		UnregisterShellFileTypes();
		m_server.UpdateRegistry(OAT_DISPATCH_OBJECT, NULL, NULL, FALSE);
		AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
	}
	// App was launched standalone or with other switches (e.g. /Register
	// or /Regserver).  Update registry entries, including typelibrary.
	else
	{
		m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
		COleObjectFactory::UpdateRegistryAll();
		AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
	}

	// 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_SHOWMAXIMIZED);
	m_pMainWnd->UpdateWindow();
	// call DragAcceptFiles only if there's a suffix
	//  In an SDI app, this should occur after ProcessShellCommand
	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	m_cpVoice.CoCreateInstance(CLSID_SpVoice);

	InitEngine();

	return TRUE;
}
示例#14
0
BOOL CCalcApp::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.
#if _MFC_VER < 0x0700
	Enable3dControls();
#endif
    // Initialize OLE 2.0 libraries
    if (!AfxOleInit())
    {
        AfxMessageBox(IDP_OLE_INIT_FAILED);
        return FALSE;
    }

	// Parse command line for automation or reg/unreg switches.
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	if (RunEmbedded() || RunAutomated())
    {
        // Register all OLE server (factories) as running.  This enables the 
        //  OLE 2.0 libraries to create objects from other applications.
        COleTemplateServer::RegisterAll();

        // Do not continue with rest of initialization.  Wait for
        // client to create a CCalcDlg object instead.
        return TRUE;
    }
	// App was launched with /Unregserver or /Unregister switch.  Remove
	// entries from the registry.
	else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
	{
		COleObjectFactory::UpdateRegistryAll(FALSE);
		AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
		return FALSE;
	}
	// App was launched standalone or with other switches (e.g. /Register
	// or /Regserver).  Update registry entries, including typelibrary.
	else
	{
		COleObjectFactory::UpdateRegistryAll();
		AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
		if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister)
			return FALSE;
	}

	
    // create a modeless dialog as the main window of the application
	//suppress warning because an object of CDialog is self-destructing
	#pragma warning (suppress: 6014)
    CCalcDlg* pDlg = new CCalcDlg;
    pDlg->SetVisible(TRUE);
    if (!pDlg->GetVisible())
    {
        AfxMessageBox(IDP_UNABLE_TO_SHOW_CALC);
		return FALSE;
    }
    pDlg->RegisterActive();

    // We are using a modeless dialog so we can translate accelerator keys 
    // against the dialog.  In order to run the main message pump, 
    // InitInstance must return TRUE even though this application is
    // a dialog-based application.
    return TRUE;
}