本文整理汇总了C++中IShellFolder::CreateViewObject方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellFolder::CreateViewObject方法的具体用法?C++ IShellFolder::CreateViewObject怎么用?C++ IShellFolder::CreateViewObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellFolder
的用法示例。
在下文中一共展示了IShellFolder::CreateViewObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDesktopShellView
static HRESULT GetDesktopShellView(
__in REFIID riid,
__out void **ppv
)
{
HRESULT hr = S_OK;
IShellWindows* psw = NULL;
HWND hwnd = NULL;
IDispatch* pdisp = NULL;
VARIANT vEmpty = {}; // VT_EMPTY
IShellBrowser* psb = NULL;
IShellFolder* psf = NULL;
IShellView* psv = NULL;
// use the shell view for the desktop using the shell windows automation to find the
// desktop web browser and then grabs its view
// returns IShellView, IFolderView and related interfaces
hr = ::CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
ExitOnFailure(hr, "Failed to get shell view.");
hr = psw->FindWindowSW(&vEmpty, &vEmpty, SWC_DESKTOP, (long*)&hwnd, SWFO_NEEDDISPATCH, &pdisp);
if (S_OK == hr)
{
hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
ExitOnFailure(hr, "Failed to get desktop window.");
hr = psb->QueryActiveShellView(&psv);
ExitOnFailure(hr, "Failed to get active shell view.");
hr = psv->QueryInterface(riid, ppv);
ExitOnFailure(hr, "Failed to query for the desktop shell view.");
}
else if (S_FALSE == hr)
{
//Windows XP
hr = SHGetDesktopFolder(&psf);
ExitOnFailure(hr, "Failed to get desktop folder.");
hr = psf->CreateViewObject(NULL, IID_IShellView, ppv);
ExitOnFailure(hr, "Failed to query for the desktop shell view.");
}
else
{
ExitOnFailure(hr, "Failed to get desktop window.");
}
LExit:
ReleaseObject(psv);
ReleaseObject(psb);
ReleaseObject(psf);
ReleaseObject(pdisp);
ReleaseObject(psw);
return hr;
}
示例2: HandleRightClickDrop
void CDropHandler::HandleRightClickDrop(void)
{
IShellFolder *pDesktop = NULL;
IShellFolder *pShellFolder = NULL;
IDropTarget *pDrop = NULL;
LPITEMIDLIST pidlDirectory = NULL;
DWORD dwe;
HRESULT hr;
hr = GetIdlFromParsingName(m_szDestDirectory,&pidlDirectory);
if(SUCCEEDED(hr))
{
hr = SHGetDesktopFolder(&pDesktop);
if(SUCCEEDED(hr))
{
hr = pDesktop->BindToObject(pidlDirectory,0,IID_IShellFolder,(void **)&pShellFolder);
if(SUCCEEDED(hr))
{
dwe = *m_pdwEffect;
hr = pShellFolder->CreateViewObject(m_hwndDrop,IID_IDropTarget,(void **)&pDrop);
if(SUCCEEDED(hr))
{
pDrop->DragEnter(m_pDataObject,MK_RBUTTON,m_ptl,&dwe);
dwe = *m_pdwEffect;
pDrop->Drop(m_pDataObject,m_grfKeyState,m_ptl,&dwe);
pDrop->DragLeave();
pDrop->Release();
}
pShellFolder->Release();
}
pDesktop->Release();
}
CoTaskMemFree(pidlDirectory);
}
}
示例3: jstringFromSTRRET
/*
* Class: sun_awt_shell_Win32ShellFolder2
* Method: doGetColumnValue
* Signature: (JJI)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL
Java_sun_awt_shell_Win32ShellFolder2_doGetColumnValue
(JNIEnv *env, jobject obj, jlong iShellFolder,
jlong jpidl, jint columnIdx)
{
HRESULT hr;
IShellFolder *pIShellFolder = (IShellFolder*) iShellFolder;
IUnknown *pIUnknown = NULL;
LPITEMIDLIST pidl = (LPITEMIDLIST) jpidl;
SHELLDETAILS sd;
hr = pIShellFolder->QueryInterface(IID_IShellFolder2, (void**)&pIUnknown);
if(SUCCEEDED (hr)) {
// The folder exposes IShellFolder2 interface
IShellFolder2 *pIShellFolder2 = (IShellFolder2*) pIUnknown;
hr = pIShellFolder2->GetDetailsOf(pidl, (UINT)columnIdx, &sd);
pIShellFolder2->Release();
if (SUCCEEDED (hr)) {
STRRET strRet = sd.str;
return jstringFromSTRRET(env, pidl, &strRet);
}
}
hr = pIShellFolder->CreateViewObject(NULL, IID_IShellDetails, (void**)&pIUnknown);
if(SUCCEEDED (hr)) {
// The folder exposes IShellDetails interface
IShellDetails *pIShellDetails = (IShellDetails*) pIUnknown;
hr = pIShellDetails->GetDetailsOf(pidl, (UINT)columnIdx, &sd);
pIShellDetails->Release();
if (SUCCEEDED (hr)) {
STRRET strRet = sd.str;
return jstringFromSTRRET(env, pidl, &strRet);
}
}
// The folder exposes neither IShellFolder2 nor IShelDetails
return NULL;
}
示例4: while
/*
* Class: sun_awt_shell_Win32ShellFolder2
* Method: doGetColumnInfo
* Signature: (J)[Lsun/awt/shell/ShellFolderColumnInfo;
*/
JNIEXPORT jobjectArray JNICALL
Java_sun_awt_shell_Win32ShellFolder2_doGetColumnInfo
(JNIEnv *env, jobject obj, jlong iShellFolder)
{
HRESULT hr;
IShellFolder *pIShellFolder = (IShellFolder*) iShellFolder;
IUnknown *pIUnknown = NULL;
jclass columnClass = env->FindClass("sun/awt/shell/ShellFolderColumnInfo");
if(NULL == columnClass) {
return NULL;
}
jmethodID columnConstructor =
env->GetMethodID(columnClass, "<init>", "(Ljava/lang/String;IIZ)V");
if(NULL == columnConstructor) {
return NULL;
}
// We'are asking the object the list of available columns
SHELLDETAILS sd;
hr = pIShellFolder->QueryInterface(IID_IShellFolder2, (void**)&pIUnknown);
if(SUCCEEDED (hr)) {
// The folder exposes IShellFolder2 interface
IShellFolder2 *pIShellFolder2 = (IShellFolder2*) pIUnknown;
// Count columns
int colNum = -1;
hr = S_OK;
do{
hr = pIShellFolder2->GetDetailsOf(NULL, ++colNum, &sd);
} while (SUCCEEDED (hr));
jobjectArray columns =
env->NewObjectArray((jsize) colNum, columnClass, NULL);
if(NULL == columns) {
pIShellFolder2->Release();
return NULL;
}
// Fill column details list
SHCOLSTATEF csFlags;
colNum = 0;
hr = S_OK;
while (SUCCEEDED (hr)) {
hr = pIShellFolder2->GetDetailsOf(NULL, colNum, &sd);
if (SUCCEEDED (hr)) {
hr = pIShellFolder2->GetDefaultColumnState(colNum, &csFlags);
if (SUCCEEDED (hr)) {
if(!(csFlags & SHCOLSTATE_HIDDEN)) {
jobject column = CreateColumnInfo(env,
&columnClass, &columnConstructor,
&sd, csFlags & SHCOLSTATE_ONBYDEFAULT);
if(!column){
pIShellFolder2->Release();
return NULL;
}
env->SetObjectArrayElement(columns, (jsize) colNum, column);
}
}
colNum++;
}
}
pIShellFolder2->Release();
return columns;
}
hr = pIShellFolder->CreateViewObject(NULL, IID_IShellDetails, (void**)&pIUnknown);
if(SUCCEEDED (hr)) {
// The folder exposes IShellDetails interface
IShellDetails *pIShellDetails = (IShellDetails*) pIUnknown;
// Count columns
int colNum = -1;
hr = S_OK;
do{
hr = pIShellDetails->GetDetailsOf(NULL, ++colNum, &sd);
} while (SUCCEEDED (hr));
jobjectArray columns =
env->NewObjectArray((jsize) colNum, columnClass, NULL);
if(NULL == columns) {
pIShellDetails->Release();
return NULL;
}
// Fill column details list
colNum = 0;
hr = S_OK;
//.........这里部分代码省略.........