コード例 #1
0
ファイル: olefact.cpp プロジェクト: anyue100/winscp
BOOL COleObjectFactory::UpdateRegistry(BOOL bRegister)
{
	if (bRegister)
		UpdateRegistry();   // will register with default m_lpszProgID

	return TRUE;
}
コード例 #2
0
/*
 *	Cleanup
 */
int CGuiThread::ExitInstance()
{
	UpdateRegistry();
	CloseSockets();	// buggy old clients do not close sockets on exit. So we imitate closing manually
	UnloadPlugins();
	DeleteWorld();

	return CWinThread::ExitInstance();
}
コード例 #3
0
/*static*/
HRESULT CTRiASOGCDBEngine::UpdateRegistry(BOOL bRegister)
{
COGISDataProviderEnum Enum;

	RETURN_FAILED_HRESULT(Enum.Open());
    while (S_OK == Enum.MoveNext()) {
		if (Enum.IsOGISProvider()) {
		// OGC Data Provider
		CComBSTR bstrProgId;

			RETURN_FAILED_HRESULT(Enum.GetProgId(&bstrProgId));
			RETURN_FAILED_HRESULT(UpdateRegistry(bRegister, Enum, bstrProgId));
		}
	}

	return _Module.UpdateRegistryFromResource(IDR_TRIASOGCDBENGINE_RGS, bRegister);
}
コード例 #4
0
ファイル: dlg_automap.cpp プロジェクト: bagdxk/openafs
BOOL DefineDosDrive(DRIVEMAP *pDrive, DDDACTION dddAction)
{
    // TCHAR szAfsPath[MAX_PATH];
    // TCHAR szDrive[3] = TEXT("?:");
   BOOL fResult = FALSE;

   if (!pDrive)
      return FALSE;

   if (dddAction == DDD_REMOVE) {
       if (!(fResult=(DisMountDOSDrive(pDrive->chDrive)==NO_ERROR)))
           Message (MB_OK | MB_ICONHAND, IDS_ERROR_UNMAP, IDS_ERROR_UNMAP_DESC, TEXT("%08lX"), GetLastError());
   } else if (dddAction == DDD_ADD) {
       if (!(fResult=(MountDOSDrive(pDrive->chDrive, pDrive->szSubmount,FALSE)==NO_ERROR)))
	   Message (MB_OK | MB_ICONHAND, IDS_ERROR_MAP, IDS_ERROR_MAP_DESC, TEXT("%08lX"), GetLastError());
   }
   /*
     Replace this code with Drive mapping routine that doesn't require different formats for each OS
     szDrive[0] = pDrive->chDrive;
     _stprintf(szAfsPath, TEXT("\\Device\\LanmanRedirector\\%s\\%s-AFS\\%s"), szDrive, szHostName, pDrive->szSubmount);

     if (dddAction == DDD_REMOVE) {
         fResult = DefineDosDevice(DDD_RAW_TARGET_PATH | DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, szDrive, szAfsPath);
	 if (!fResult)
             Message (MB_OK | MB_ICONHAND, IDS_ERROR_UNMAP, IDS_ERROR_UNMAP_DESC, TEXT("%08lX"), GetLastError());
     } else if (dddAction == DDD_ADD) {
          fResult = DefineDosDevice(DDD_RAW_TARGET_PATH, szDrive, szAfsPath);
	  if (!fResult)
	      Message (MB_OK | MB_ICONHAND, IDS_ERROR_MAP, IDS_ERROR_MAP_DESC, TEXT("%08lX"), GetLastError());
     }

    */
   if (fResult)
       UpdateRegistry(pDrive, dddAction == DDD_REMOVE);

   return fResult;
}
コード例 #5
0
ファイル: wordpad.cpp プロジェクト: jetlive/skiaming
BOOL CWordPadApp::InitInstance()
{
	ParseCommandLine(cmdInfo);

	if (::FindWindow(szWordPadClass, NULL) && IsDocOpen(cmdInfo.m_strFileName))
		return FALSE;

	SetRegistryKey(szRegKey);
	LoadOptions();

	Enable3dControls();
	CSplashWnd splash;
	BOOL bSplash = cmdInfo.m_bShowSplash;
	if (!cmdInfo.m_bRunEmbedded)
	{
		switch (m_nCmdShow)
		{
			case SW_HIDE:
			case SW_SHOWMINIMIZED:
			case SW_MINIMIZE:
			case SW_SHOWMINNOACTIVE:
				bSplash = FALSE;
				break;
			case SW_RESTORE:
			case SW_SHOW:
			case SW_SHOWDEFAULT:
			case SW_SHOWNA:
			case SW_SHOWNOACTIVATE:
			case SW_SHOWNORMAL:
			case SW_SHOWMAXIMIZED:
				if (m_bMaximized)
					m_nCmdShow = SW_SHOWMAXIMIZED;
				break;
		}
	}
	else
	{
		//Excel 4 will start OLE servers minimized
		m_nCmdShow = SW_SHOWNORMAL;
	}
	int nCmdShow = m_nCmdShow;

	if (bSplash)
	{
		// only show splash if not embedded
		splash.Create(NULL);
		splash.ShowWindow(SW_SHOW);
		splash.UpdateWindow();
	}

	LoadAbbrevStrings();

#ifdef CREATE_DEV_NAMES
	m_hDevNames = CreateDevNames();
#else
	m_hDevNames = NULL;
#endif
	NotifyPrinterChanged((m_hDevNames == NULL));

	free((void*)m_pszHelpFilePath);
	m_pszHelpFilePath = _T("WORDPAD.HLP");

	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	RegisterFormats();

	// Initialize RichEdit control
	if (LoadLibrary(_T("RICHED32.DLL")) == NULL)
	{
		AfxMessageBox(IDS_RICHED_LOAD_FAIL, MB_OK|MB_ICONEXCLAMATION);
		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.

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Initialize all Managers for usage. They are automatically constructed
	// if not yet present
	SetRegistryBase (_T("SettingsPro"));

	InitContextMenuManager();
	InitKeyboardManager();

	InitTooltipManager();

	CMFCToolTipInfo params;
	params.m_bVislManagerTheme = TRUE;

	theApp.GetTooltipManager ()->SetTooltipParams (
		0xFFFF,
		RUNTIME_CLASS (CMFCToolTipCtrl),
		&params);

	EnableTearOffMenus (NULL, ID_FREE_TEAROFF1, ID_FREE_TEAROFF2);

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	DocTemplate.SetContainerInfo(IDR_CNTR_INPLACE);
	DocTemplate.SetServerInfo(
		IDR_SRVR_EMBEDDED, IDR_SRVR_INPLACE,
		RUNTIME_CLASS(CInPlaceFrame));

	// 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, &DocTemplate, TRUE);
		// Note: SDI applications register server objects only if /Embedding
		//   or /Automation is present on the command line.

	// Check to see if launched as OLE 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();
		AfxOleSetUserCtrl(FALSE);

		// Application was run with /Embedding or /Automation.  Don't show the
		//  main window in this case.
		return TRUE;
	}

	// make sure the main window is showing
	m_bPromptForType = FALSE;
	OnFileNew();
	m_bPromptForType = TRUE;
	// destroy splash window
	if (cmdInfo.m_bShowSplash)
		splash.DestroyWindow();
	m_nCmdShow = -1;
	if (m_pMainWnd == NULL) // i.e. OnFileNew failed
		return FALSE;

	if (!cmdInfo.m_strFileName.IsEmpty())   // open an existing document
		m_nCmdShow = nCmdShow;
	
	// Dispatch commands specified on the command line
	if (cmdInfo.m_nShellCommand != CCommandLineInfo::FileNew &&
		!ProcessShellCommand(cmdInfo))
	{
		return FALSE;
	}

	LoadCustomState ();

	// Enable File Manager drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// When a server application is launched stand-alone, it is a good idea
	//  to update the system registry in case it has been damaged.
	// do registry stuff in separate thread
#ifndef _UNICODE
	if (m_bWin31) // no threads on Win32s
		UpdateRegistry();
	else
#endif
		AfxBeginThread(DoRegistry, this, THREAD_PRIORITY_IDLE);

	if (afxGlobalData.m_nBitsPerPixel < 16)
	{
		AfxMessageBox(IDS_WRONG_DISPLAY_SETTINGS);
	}

	// Set application general look:
	CAppLookDlg dlg (TRUE);
	dlg.DoModal ();

	return TRUE;
}
コード例 #6
0
EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, int nShowCmd)
{
    QT_USE_NAMESPACE

    qAxOutProcServer = true;
    GetModuleFileName(0, qAxModuleFilename, MAX_PATH);
    qAxInstance = hInstance;

    QByteArray cmdParam = QString::fromWCharArray(GetCommandLine()).toLocal8Bit();
    QList<QByteArray> cmds = cmdParam.split(' ');
    QByteArray unprocessed;

    int nRet = 0;
    bool run = true;
    bool runServer = false;
    for (int i = 0; i < cmds.count(); ++i) {
        QByteArray cmd = cmds.at(i).toLower();
        if (cmd == "-activex" || cmd == "/activex" || cmd == "-embedding" || cmd == "/embedding") {
            runServer = true;
        } else if (cmd == "-unregserver" || cmd == "/unregserver") {
            nRet = UpdateRegistry(false);
            run = false;
            break;
        } else if (cmd == "-regserver" || cmd == "/regserver") {
            nRet = UpdateRegistry(true);
            run = false;
            break;
        } else if (cmd == "-dumpidl" || cmd == "/dumpidl") {
            ++i;
            if (i < cmds.count()) {
                QByteArray outfile = cmds.at(i);
                ++i;
                QByteArray version;
                if (i < cmds.count() && (cmds.at(i) == "-version" || cmds.at(i) == "/version")) {
                    ++i;
                    if (i < cmds.count())
                        version = cmds.at(i);
                    else
                        version = "1.0";
                }

                nRet = DumpIDL(QString::fromLatin1(outfile.constData()), QString::fromLatin1(version.constData()));
            } else {
                qWarning("Wrong commandline syntax: <app> -dumpidl <idl file> [-version <x.y.z>]");
            }
            run = false;
            break;
        } else {
            unprocessed += cmds.at(i) + ' ';
        }
    }

    if (run) {
        if (SUCCEEDED(CoInitialize(0))) {
            int argc;
            QVector<char*> argv(8);
            qWinMain(hInstance, hPrevInstance, unprocessed.data(), nShowCmd, argc, argv);
            qAxInit();
            if (runServer)
                QAxFactory::startServer();
            nRet = ::main(argc, argv.data());
            QAxFactory::stopServer();
            qAxCleanup();
            CoUninitialize();
        } else {
            qErrnoWarning("CoInitialize() failed.");
            nRet = -1;
        }
    }

    return nRet;
}
コード例 #7
0
STDAPI DllUnregisterServer()
{
    return UpdateRegistry(false);
}
コード例 #8
0
STDAPI DllRegisterServer()
{
    return UpdateRegistry(true);
}