本文整理汇总了C++中IShellView::GetItemObject方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellView::GetItemObject方法的具体用法?C++ IShellView::GetItemObject怎么用?C++ IShellView::GetItemObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellView
的用法示例。
在下文中一共展示了IShellView::GetItemObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyCom_BuildPyException
// @pymethod <o PyIUnknown>|PyIShellView|GetItemObject|Description of GetItemObject.
PyObject *PyIShellView::GetItemObject(PyObject *self, PyObject *args)
{
IShellView *pISV = GetI(self);
if ( pISV == NULL )
return NULL;
// @pyparm int|uItem||Description for uItem
// @pyparm <o PyIID>|riid||Description for riid
PyObject *obriid;
UINT uItem;
IID riid;
IUnknown *ppv;
if ( !PyArg_ParseTuple(args, "iO:GetItemObject", &uItem, &obriid) )
return NULL;
BOOL bPythonIsHappy = TRUE;
if (!PyWinObject_AsIID(obriid, &riid)) bPythonIsHappy = FALSE;
if (!bPythonIsHappy) return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pISV->GetItemObject( uItem, riid, (void **)&ppv );
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pISV, IID_IShellView );
PyObject *obppv;
obppv = PyCom_PyObjectFromIUnknown(ppv, riid, FALSE);
PyObject *pyretval = Py_BuildValue("O", obppv);
Py_XDECREF(obppv);
return pyretval;
}
示例2: MyShellDispatch_ShellDispatchProc
static int MyShellDispatch_ShellDispatchProc(const shell_dispatch_handler_t handler, void *const data)
{
int iSuccess = SHELL_DISPATCH_FAILED;
IShellWindows *psw = NULL;
HRESULT hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
if(SUCCEEDED(hr))
{
HWND desktopHwnd = 0;
IDispatch* pdisp = NULL;
variant_t vEmpty;
if(S_OK == psw->FindWindowSW(vEmpty, vEmpty, SWC_DESKTOP, (long*)&desktopHwnd, SWFO_NEEDDISPATCH, &pdisp))
{
if(VALID_HANDLE(desktopHwnd))
{
IShellBrowser *psb;
hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
if(SUCCEEDED(hr))
{
IShellView *psv = NULL;
hr = psb->QueryActiveShellView(&psv);
if(SUCCEEDED(hr))
{
IDispatch *pdispBackground = NULL;
HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
if(SUCCEEDED(hr))
{
MyShellDispatch_AllowSetForegroundWindow(desktopHwnd);
IShellFolderViewDual *psfvd = NULL;
HRESULT hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
if(SUCCEEDED(hr))
{
IDispatch *pdisp = NULL;
hr = psfvd->get_Application(&pdisp);
if(SUCCEEDED(hr))
{
IShellDispatch2 *pShellDispatch;
hr = pdisp->QueryInterface(IID_PPV_ARGS(&pShellDispatch));
if(SUCCEEDED(hr))
{
iSuccess = handler(pShellDispatch, data);
}
RELEASE_OBJ(pdisp);
}
RELEASE_OBJ(psfvd);
}
RELEASE_OBJ(pdispBackground);
}
RELEASE_OBJ(psv);
}
RELEASE_OBJ(psb);
}
}
RELEASE_OBJ(pdisp);
}
RELEASE_OBJ(psw);
}
return iSuccess;
}
示例3: ShellExecAsUser
int ShellExecAsUser(const TCHAR *pcOperation, const TCHAR *pcFileName, const TCHAR *pcParameters, const HWND parentHwnd)
{
/*BOOL bRet;
HANDLE hToken;
HANDLE hNewToken;
// Notepad is used as an example
//WCHAR wszProcessName[MAX_PATH] = L"C:\\Windows\\Notepad.exe";
// Low integrity SID: 0x1000 = 4096. To use Medium integrity, use 0x2000 = 8192
WCHAR wszIntegritySid[20] = L"S-1-16-4096";
PSID pIntegritySid = NULL;
TOKEN_MANDATORY_LABEL TIL = {0};
PROCESS_INFORMATION ProcInfo = {0};
STARTUPINFO StartupInfo = {0};
ULONG ExitCode = 0;
if (OpenProcessToken(GetCurrentProcess(), MAXIMUM_ALLOWED, &hToken)) {
if (DuplicateTokenEx(hToken, MAXIMUM_ALLOWED, NULL, SecurityImpersonation, TokenPrimary, &hNewToken)) {
if (ConvertStringSidToSid(wszIntegritySid, &pIntegritySid)) {
TIL.Label.Attributes = SE_GROUP_INTEGRITY;
TIL.Label.Sid = pIntegritySid;
// Set the process integrity level
if (SetTokenInformation(hNewToken, TokenIntegrityLevel, &TIL, sizeof(TOKEN_MANDATORY_LABEL) + GetLengthSid(pIntegritySid))) {
// Create the new process at Low integrity
bRet = CreateProcessAsUser(hNewToken, NULL, (LPWSTR)pcFileName, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcInfo);
}
LocalFree(pIntegritySid);
}
CloseHandle(hNewToken);
}
CloseHandle(hToken);
}
return bRet;*/
int bSuccess = 0;
HRESULT hr = CoInitialize(NULL);
if((hr == S_FALSE) || (hr == S_OK))
{
IShellWindows *psw = NULL;
hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
if(SUCCEEDED(hr))
{
HWND hwnd = 0;
IDispatch* pdisp = NULL;
variant_t vEmpty;
if(S_OK == psw->FindWindowSW(&vEmpty.get(), &vEmpty.get(), SWC_DESKTOP, (long*)&hwnd, SWFO_NEEDDISPATCH, &pdisp))
{
if((hwnd != NULL) && (hwnd != INVALID_HANDLE_VALUE))
{
IShellBrowser *psb;
hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
if(SUCCEEDED(hr))
{
IShellView *psv = NULL;
hr = psb->QueryActiveShellView(&psv);
if(SUCCEEDED(hr))
{
IDispatch *pdispBackground = NULL;
hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
if (SUCCEEDED(hr))
{
IShellFolderViewDual *psfvd = NULL;
hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
if (SUCCEEDED(hr))
{
IDispatch *pdisp2 = NULL;
hr = psfvd->get_Application(&pdisp2);
if (SUCCEEDED(hr))
{
IShellDispatch2 *psd;
hr = pdisp2->QueryInterface(IID_PPV_ARGS(&psd));
if(SUCCEEDED(hr))
{
variant_t verb(pcOperation);
variant_t file(pcFileName);
variant_t para(pcParameters);
variant_t show(SW_SHOWNORMAL);
hr = psd->ShellExecute(file.get().bstrVal, para.get(), vEmpty.get(), verb.get(), show.get());
if(SUCCEEDED(hr)) bSuccess = 1;
psd->Release();
psd = NULL;
}
pdisp2->Release();
pdisp2 = NULL;
}
}
pdispBackground->Release();
pdispBackground = NULL;
}
psv->Release();
psv = NULL;
}
psb->Release();
psb = NULL;
//.........这里部分代码省略.........
示例4: ShellExecAsUser_ShellDispatchProc
static int ShellExecAsUser_ShellDispatchProc(const TCHAR *pcOperation, const TCHAR *pcFileName, const TCHAR *pcParameters, const HWND parentHwnd)
{
int iSuccess = SHELLEXECASUSER_ERROR_FAILED;
IShellWindows *psw = NULL;
HRESULT hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
if(SUCCEEDED(hr))
{
HWND hwnd = 0;
IDispatch* pdisp = NULL;
variant_t vEmpty;
if(S_OK == psw->FindWindowSW(vEmpty, vEmpty, SWC_DESKTOP, (long*)&hwnd, SWFO_NEEDDISPATCH, &pdisp))
{
if((hwnd != NULL) && (hwnd != INVALID_HANDLE_VALUE))
{
IShellBrowser *psb;
hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
if(SUCCEEDED(hr))
{
IShellView *psv = NULL;
hr = psb->QueryActiveShellView(&psv);
if(SUCCEEDED(hr))
{
IDispatch *pdispBackground = NULL;
HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
if (SUCCEEDED(hr))
{
IShellFolderViewDual *psfvd = NULL;
hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
if (SUCCEEDED(hr))
{
IDispatch *pdisp = NULL;
hr = psfvd->get_Application(&pdisp);
if (SUCCEEDED(hr))
{
IShellDispatch2 *psd;
hr = pdisp->QueryInterface(IID_PPV_ARGS(&psd));
if(SUCCEEDED(hr))
{
DispatchPendingMessages(125);
variant_t verb(pcOperation);
variant_t file(pcFileName);
variant_t para(pcParameters);
variant_t show(SW_SHOWNORMAL);
hr = psd->ShellExecute(file, para, vEmpty, verb, show);
if(SUCCEEDED(hr))
{
iSuccess = SHELLEXECASUSER_ERROR_SUCCESS;
}
psd->Release();
psd = NULL;
}
pdisp->Release();
pdisp = NULL;
}
}
pdispBackground->Release();
pdispBackground = NULL;
}
psv->Release();
psv = NULL;
}
psb->Release();
psb = NULL;
}
}
pdisp->Release();
pdisp = NULL;
}
psw->Release();
psw = NULL;
}
return iSuccess;
}