Article View: borland.public.cppbuilder.nativeapi
Article #6414IContextMenu for Explorer
From: nicolasr
Date: Mon, 16 May 2005 01:26
Date: Mon, 16 May 2005 01:26
56 lines
2341 bytes
2341 bytes
Hi,
I'm trying to get the context menu entries of the menu that is
opened when I right-click inside the background of the folder
view in the right Explorer pane. For example for D:\\.
I'm not sure whether I understood the Shell documentation correctly
but after reading up on the interfaces I tried the following test code:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WideString path = "D:\\";
IShellFolder* desktop = NULL;
ITEMIDLIST* pidl = NULL;
IShellFolder* folder = NULL;
IContextMenu* menu = NULL;
OleCheck(SHGetDesktopFolder(&desktop));
try
{
OleCheck(desktop->ParseDisplayName(NULL, NULL, path.c_bstr(), NULL,
&pidl, 0));
OleCheck(desktop->BindToObject(pidl, NULL, IID_IShellFolder,
(void**)&folder));
OleCheck(folder->CreateViewObject(Handle, IID_IContextMenu,
(void**)&menu));
char buffer[50] = {0};
OleCheck(menu->GetCommandString(0, GCS_VERBA, NULL, buffer, 49));
ShowMessage(buffer);
}
__finally
{
if(menu)
menu->Release();
if(pidl)
CoTaskMemFree(pidl);
if(folder)
folder->Release();
if(desktop)
desktop->Release();
}
}
Problem: the call to GetCommandString() fails with 'Falscher Parameter'
(Invalid argument??)
Does anyone have an idea what could be wrong?
thanks,
Nick
Technical Details
Message-ID:
<4287f6c1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,7e49abe43ea24b0d,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net> Newsgroups: borland.public.cppbuilder.nativeapi Subject: IContextMenu for Explorer Date: Mon, 16 May 2005 03:26:22 +0200 Lines: 58 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 84.174.167.138 Message-ID: <4287f6c1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1116206785 84.174.167.138 (15 May 2005 18:26:25 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail