Article View: borland.public.cppbuilder.nativeapi
Article #5971Re: Shell popup menu
From: Remy Lebeau (TeamB)
Date: Wed, 22 Jun 2005 20:20
Date: Wed, 22 Jun 2005 20:20
117 lines
4187 bytes
4187 bytes
"qyte" <gyte@vivodinet.gr> wrote in message
news:42b9471a$1@newsgroups.borland.com...
> I cannot seem to find what it is i have to pass where the REFIID
> riid parameter is required in two of the above functions.
You use IID_IShellFolder and IID_IContextMenu.
> could you post a reply of some code?
LPITEMIDLIST GetNextItemID(LPCITEMIDLIST pidl)
{
if( pidl == NULL )
return NULL;
int cb = pidl->mkid.cb;
if( cb == 0 )
return NULL;
pidl = (LPITEMIDLIST) (((LPBYTE) pidl) + cb);
return (pidl->mkid.cb == 0) ? NULL : (LPITEMIDLIST) pidl;
}
UINT GetSize(LPCITEMIDLIST pidl)
{
UINT cbTotal = 0;
if( pidl != NULL )
{
cbTotal += sizeof(pidl->mkid.cb);
while( pidl != NULL )
{
cbTotal += pidl->mkid.cb;
pidl = GetNextItemID(pidl);
}
}
return cbTotal;
}
LPITEMIDLIST MakeCopy(LPCITEMIDLIST pidl)
{
LPITEMIDLIST pidlTemp = (LPITEMIDLIST) pidl;
UINT cb = GetSize(pidl);
LPITEMIDLIST pidlRet = (LPITEMIDLIST) CoTaskMemAlloc(cb);
if( pidlRet != NULL )
CopyMemory(pidlRet, pidl, cb);
return pidlRet;
}
LPITEMIDLIST GetChildID(LPITEMIDLIST pidl)
{
LPITEMIDLIST pidlRet = NULL;
if( pidl != NULL )
{
if( pidl->mkid.cb )
{
LPITEMIDLIST pidlNext = pidl;
while( pidlNext )
{
pidl = pidlNext;
pidlNext = GetNextItemID(pidl);
}
pidlRet = MakeCopy(pidl);
if( pidlRet == NULL )
return NULL;
pidl->mkid.cb = 0;
}
return pidlRet;
}
{
IShellFolder *Desktop = NULL;
if( SUCCEEDED(SHGetDesktopFolder(&Desktop)) )
{
LPITEMIDLIST pidl = NULL;
ULONG ulEaten = 0;
WideString Path = Label1->Caption;
if( SUCCEEDED(Desktop->ParseDisplayName(NULL, NULL, Path,
&ulEaten, &pidl, NULL)) )
{
LPITEMIDLIST pidlChild = GetChildID(pidl);
if( pidlChild != NULL )
{
IShellFolder *ParentFolder = NULL;
if( SUCCEEDED(Desktop->BindToObject(pidl, NULL,
IID_IShellFolder, (LPVOID*)&ParentFolder)) )
{
IContextMenu *menu = NULL;
if( SUCCEEDED(ParentFolder->GetUIObjectOf(NULL, 1,
(LPCITEMIDLIST*)&pidlChild, IID_IContextMenu, NULL, (LPVOID*)&menu)) )
{
Label1->Caption =
menu->QueryContextMenu(PopupMenu->Handle, 0, 1, 100, CMF_NORMAL);
menu->Release();
PopupMenu->Popup(10, 10);
}
}
ParentFolder->Release();
}
}
CoTaskFreeMem(pidl);
}
Desktop->Release();
}
Gambit
Technical Details
Message-ID:
<42b9c800$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42b77365@newsgroups.borland.com> <42b781a4@newsgroups.borland.com> <42b9471a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,49d4c9bc0c0cea4b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <42b77365@newsgroups.borland.com> <42b781a4@newsgroups.borland.com> <42b9471a$1@newsgroups.borland.com> Subject: Re: Shell popup menu Date: Wed, 22 Jun 2005 13:20:13 -0700 Lines: 119 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <42b9c800$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1119471616 68.69.17.41 (22 Jun 2005 13:20:16 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail