예제 #1
0
void GetExplorerWindows(std::vector<PairHwndPath>& windows, BOOL needPaths) {
    IShellWindows *psw;
    if(SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (void**)&psw))) {
        VARIANT v;
        V_VT(&v) = VT_I4;
        IDispatch* pdisp;
        for(V_I4(&v) = 0; psw->Item(v, &pdisp) == S_OK; V_I4(&v)++) {
            IWebBrowserApp *pwba;
            if(SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (void**)&pwba))) {
                PairHwndPath pair;
                if(SUCCEEDED(pwba->get_HWND((LONG_PTR*)&pair.hwnd))) {
                    IServiceProvider *psp;
                    if(needPaths && SUCCEEDED(pwba->QueryInterface(IID_IServiceProvider, (void**)&psp))) {
                        IShellBrowser *psb;
                        if(SUCCEEDED(psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&psb))) {
                            IShellView *psv;
                            if(SUCCEEDED(psb->QueryActiveShellView(&psv))) {
                                IFolderView *pfv;
                                if(SUCCEEDED(psv->QueryInterface(IID_IFolderView, (void**)&pfv))) {
                                    IPersistFolder2 *ppf2;
                                    if(SUCCEEDED(pfv->GetFolder(IID_IPersistFolder2, (void**)&ppf2))) {
                                        LPITEMIDLIST pidlFolder;
                                        if(SUCCEEDED(ppf2->GetCurFolder(&pidlFolder))) {
                                            if(!SHGetPathFromIDList(pidlFolder, pair.path)) {
                                                IShellFolder* psf;
                                                LPCITEMIDLIST pidlLast;
                                                if(SUCCEEDED(SHBindToParent(pidlFolder, IID_IShellFolder, (void**)&psf, &pidlLast))) {
                                                    STRRET strret;
                                                    if(SUCCEEDED(psf->GetDisplayNameOf(pidlLast, 0x8000, &strret))) {
                                                        StrRetToBuf(&strret, pidlLast, pair.path, MAX_PATH);
                                                    }
                                                    else {
                                                        pair.path[0] = 0;
                                                    }
                                                    psf->Release();
                                                }
                                            }
                                            CoTaskMemFree(pidlFolder);
                                        }
                                        ppf2->Release();
                                    }
                                    pfv->Release();
                                }
                                psv->Release();
                            }
                            psb->Release();
                        }
                        psp->Release();
                    }
                    windows.push_back(pair);
                }
                pwba->Release();
            }
            pdisp->Release();
        }
        psw->Release();
    }
}
예제 #2
0
파일: Rename.cpp 프로젝트: SpivEgin/stexbar
HRESULT CDeskBand::GetIServiceProvider(HWND hwnd, IServiceProvider ** pServiceProvider)
{
    HRESULT hr = E_FAIL;
    if (m_pSite)
        hr = m_pSite->QueryInterface(IID_IServiceProvider, (LPVOID*)pServiceProvider);
    else
    {
        // we don't have a site, so we try finding the explorer window by enumerating
        // all explorer instances and compare that to the parent of hwnd.
        IShellWindows *psw;
        if (SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (LPVOID*)&psw)))
        {
            VARIANT v;
            V_VT(&v) = VT_I4;
            IDispatch  *pdisp;
            BOOL fFound = FALSE;
            long count = -1;
            if (SUCCEEDED(psw->get_Count(&count)))
            {
                for (V_I4(&v) = 0; !fFound && (V_I4(&v) < count) && SUCCEEDED(psw->Item(v, &pdisp)); V_I4(&v)++)
                {
                    if (pdisp)
                    {
                        IWebBrowserApp *pwba;
                        if (SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (LPVOID*)&pwba)))
                        {
                            HWND hwndWBA;
                            if (SUCCEEDED(pwba->get_HWND((LONG_PTR*)&hwndWBA)))
                            {
                                if ((hwndWBA == hwnd)||(hwndWBA == ::GetParent(hwnd)))
                                {
                                    fFound = TRUE;
                                    hr = pwba->QueryInterface(IID_IServiceProvider, (void**)pServiceProvider);
                                }
                            }
                            pwba->Release();
                        }
                        pdisp->Release();
                    }
                }
            }
            psw->Release();
        }
    }
    return hr;
}
예제 #3
0
		TEXT("雏龙"),TEXT("幼龙"),TEXT("鸭嘴龙"),TEXT("双棘龙"),
		TEXT("迅龙"),TEXT("雷龙"),TEXT("甲龙"),TEXT("角龙"),
		TEXT("剑龙"),TEXT("黄金龙"),TEXT("霸王龙"),TEXT("北海冥龙"),
		TEXT("南海狂龙"),TEXT("西海魔龙"),TEXT("东海神龙"),TEXT("中华圣龙"),
	};
	for (int i=0;i<CountArray(lScoreInfo_2);i++)
	{
		if (score<lScoreInfo_2[i]) return pszOrderName_2[i];
	}
	return pszOrderName_2[17];
}

float CLogic::AssertUserPer(LONG score)
{
	LONG lScoreInfo_2[18]=
	{
		0L,50L,100L,200L,500L,800L,1200L,2000L,3000L,5000L,8000L,12000L,15000L,18000L,25000L,40000L,60000L,
	};
	for (int i=0;i<CountArray(lScoreInfo_2);i++)
	{
		if (score<lScoreInfo_2[i]&&i!=0) 
			return (float)(100.0*(score-lScoreInfo_2[i-1])/(lScoreInfo_2[i]-lScoreInfo_2[i-1]));
		else
		if (score<lScoreInfo_2[i]&&score<0&&i==0)
			return 0.0;
	}
	return 100.0;
}

void CLogic::OpenUrl(CString url)
{
	HRESULT hr;
	IWebBrowserApp* pWBApp = NULL; // Derived from IWebBrowser
	BSTR bstrURL = NULL, bstrHeaders = NULL;
	VARIANT vFlags = {0},
		vTargetFrameName = {0},
		vPostData = {0},
		vHeaders = {0};

	if (FAILED(hr = CoInitialize(NULL)))
	{
		return;
	}

	if (FAILED(hr = CoCreateInstance(CLSID_InternetExplorer,
		NULL,
		CLSCTX_SERVER,
		IID_IWebBrowserApp,
		(LPVOID*)&pWBApp)))
	{
		if (bstrURL) SysFreeString(bstrURL);
		if (bstrHeaders) SysFreeString(bstrHeaders);
		VariantClear(&vPostData);
		if (pWBApp) pWBApp->Release();
		CoUninitialize();
		return;
	}

	bstrURL = url.AllocSysString();
	if (!bstrURL)
	{
		if (bstrURL) SysFreeString(bstrURL);
		if (bstrHeaders) SysFreeString(bstrHeaders);
		VariantClear(&vPostData);
		if (pWBApp) pWBApp->Release();
		CoUninitialize();