Click here to Skip to main content
Email Password   helpLost your password?

Find Target menu selected - findtarget.gif

Introduction

This shell extension will add a new option to the Context menu of .lnk (Shortcut) files. I've always been annoyed that to Perform a find target, you have to right click properties, then click find target. There doesn't seem to be a direct api call that simulates what the shell does so I've hunted around, and come up with this, which uses a CreateProcess, ShellExecute, and didn't seem to highlight the file.

Background

After reading Michael Dunn's articles on shell extension (well the first couple so far), I took the examples and came up with this. http://www.codeproject.com/shell/shellextguide1.asp

Using the code

To use the extension, either just regsvr32 it, or Recompile and Register.

Points of Interest

There is a quirk still in here that sometimes the selected file doesn't highlight. (Anyone with any clues, assistance would be greatly appreciated)

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralGreat Assisting Tool
chessgod101
9:23 10 Jan '10  
Thank You. You have made my work a lot easier. Keep up the good work.
AnswerHow to install in 3 steps!
cherwally
5:29 19 Sep '09  
Open archive, extract DLL file and move it to:

C:\Windows\System32\FindTarget.dll


Open RUN command from StartUp,
paste the command line written below and hit Enter!
Ready Wink


regsvr32 FindTarget.dll
Generaloh! thank you Paul!!!!
bbsoft
16:53 3 Aug '09  
it's very useful!!
Generalcontext not working solved
alxnto
10:39 22 Jan '09  
Hi, I just signed to thank the author of this useful tool and share the solution of a little problem I had.

One day I noticed that findtarget and other context menus like winrar stopped working so I installed shellexview tool to find the cause of this.

It turned out to be DWFShellExt Class from Autodesk. I just disabled it and everything is fine.
Generalxp64
Tilo Kühn
2:40 9 May '08  
hi there,

has anyone an idea how i would get this nice tool running under xp64?
the registration succeeds but it wont show up in the popup even after rebooting the machine.

any hints?

thanks
tilo
GeneralGreat Tool
charlie markwick
22:17 8 Dec '07  
I've been using this for a few years now on each successive PC I use. It saves me so much time and I wanted to say thanks.
GeneralDifferent behaviour on expanded start menu to s/c's in an explorer pane
dalchina
17:13 24 Aug '07  
Hi,
If I right click on a shortcut on an expanded start menu, then 'Find Target' the folder containing the file the s/c points to is displayed.

If I right click on a shortcut on the desktop, an explorer window opens displaying the desktop, not the folder containing the file the shortcut points to.

If I right click on a shortcut in an explorer pane, Find Target is not displayed.

David Lawrie (XP Pro).

David A Lawrie

GeneralHow to get the route of Shortcut
Yao1130
16:44 9 Dec '04  
HI~


How to get the route of Shortcut Path??

Can you tell me function or code

Thx!
Generalhigfails if the target directory is open
Martijn
2:59 1 Oct '03  
if the target directory is open in the shell, the window is shown, but the highlighting doesn't work...
Generala very valuable tool
Bill Hart
17:52 26 Aug '03  
[To use the extension, either just regsvr32 it, or . . . . .]

Never having used regsvr32 before I was a little in doubt about what to do but it worked first try (actually 2nd try - had to copy "FindTarget.dll" to System32 folder) and I expect this will be a very valuable tool for me.

Thanks Paul

Bill Hart


(sorry about my unfamiliarity with posting msgs)
Generalmuch easier/more reliable way to do this
chrisg
13:20 23 Mar '03  
the API SHOpenFolderAndSelectItems() does this in much less code.

give it the idlist from the shortcut and away you go.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shopenfolderandselectitems.asp

Chris Guzak (ms)
GeneralRe: much easier/more reliable way to do this
Paul Farry
16:01 23 Mar '03  
This call appears to be only for XP or better.

Anything comparable for W2k?


GeneralRe: much easier/more reliable way to do this
chrisg
17:39 26 Mar '03  
this is built on top of features that do exist in Win2K.
CLSID_ShellWindows/IShellWindows can be used to enumerate open folder
windows and to get to the FolderView (IShellView/IFolderView interfaces)
object that is hosted there. below is some code, with supporting helpers
that demonstrate some of this (some of these helpers are only in XP
but those too can be implemented on top of the shell architecture in Win2K).


---- code that uses shell windows objects and gets a reference to the views in those windows ---


#define IID_PPV_ARG(IType, ppType) IID_##IType,
reinterpret_cast(static_cast(ppType))
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))

STDAPI DisplayNameOf(IShellFolder *psf, LPCITEMIDLIST pidl, DWORD flags,
PWSTR psz, UINT cch)
{
*psz = 0;
STRRET sr;
HRESULT hr = psf->GetDisplayNameOf(pidl, flags, &sr);
if (SUCCEEDED(hr))
hr = StrRetToBufW(&sr, pidl, psz, cch);
return hr;
}

STDAPI_(DWORD) SHGetAttributes(IShellFolder *psf, LPCITEMIDLIST pidl, DWORD
dwAttribs)
{
// like SHBindToObject, if psf is NULL, use absolute pidl
LPCITEMIDLIST pidlChild;
if (!psf)
{
SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlChild);
}
else
{
psf->AddRef();
pidlChild = pidl;
}

DWORD dw = 0;
if (psf)
{
dw = dwAttribs;
dw = SUCCEEDED(psf->GetAttributesOf(1, (LPCITEMIDLIST *)&pidlChild,
&dw)) ? (dwAttribs & dw) : 0;
psf->Release();
}

return dw;
}

STDAPI IUnknown_QueryService(IUnknown* punk, REFGUID guidService, REFIID
riid, void **ppv)
{
*ppv = NULL;
HRESULT hr = E_FAIL;
if (punk)
{
IServiceProvider *psp;
hr = punk->QueryInterface(IID_PPV_ARG(IServiceProvider, &psp));
if (SUCCEEDED(hr))
{
hr = psp->QueryService(guidService, riid, ppv);
psp->Release();
}
}
return hr;
}

STDAPI SHGetIDListFromUnk(IUnknown *punk, LPITEMIDLIST *ppidl)
{
HRESULT hr = E_NOINTERFACE;

*ppidl = NULL;

IPersistFolder2 *ppf;
if (punk && SUCCEEDED(punk->QueryInterface(IID_PPV_ARG(IPersistFolder2,
&ppf))))
{
hr = ppf->GetCurFolder(ppidl);
ppf->Release();
}
return hr;
}

HRESULT SHGetName(LPCITEMIDLIST pidl, DWORD gdnFlags, PTSTR psz, UINT cch)
{
IShellFolder *psfDesktop;
HRESULT hr = SHGetDesktopFolder(&psfDesktop);
if (SUCCEEDED(hr))
{
IShellFolder *psf;
LPCITEMIDLIST pidlChild;
hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf),
&pidlChild);
if (SUCCEEDED(hr))
{
hr = DisplayNameOf(psf, pidlChild, gdnFlags, psz, cch);
}
psfDesktop->Release();
}
return hr;
}

HRESULT ViewFromWebBrowserApp(IWebBrowserApp *pwba, REFIID riid, void **ppv)
{
IShellBrowser* psb;
HRESULT hr = IUnknown_QueryService(pwba, SID_STopLevelBrowser,
IID_PPV_ARG(IShellBrowser, &psb));
if (SUCCEEDED(hr))
{
IShellView* psv;
hr = psb->QueryActiveShellView(&psv);
if (SUCCEEDED(hr))
{
hr = psv->QueryInterface(riid, ppv);
psv->Release();
}
psb->Release();
}
return hr;
}

HWND WindowFromUnk(IUnknown *punk)
{
HWND hwnd = NULL;
IOleWindow *pow;
if (SUCCEEDED(punk->QueryInterface(IID_PPV_ARG(IOleWindow, &pow))))
{
pow->GetWindow(&hwnd);
pow->Release();
}
return hwnd;
}

STDAPI FindWindowByHWND(HWND hwnd, REFIID riid, void **ppv)
{
HRESULT hr = E_FAIL;
*ppv = NULL;

IShellWindows* psw;
if (SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL,
IID_PPV_ARG(IShellWindows, &psw))))
{
VARIANT v;
v.vt = VT_I4;

IDispatch *pdispWBA;
for (v.intVal = 0; FAILED(hr) && S_OK == psw->Item(v, &pdispWBA);
v.intVal++)
{
IWebBrowserApp *pwba;
if
(SUCCEEDED(pdispWBA->QueryInterface(IID_PPV_ARG(IWebBrowserApp, &pwba))))
{
HWND hwndWBA;
if (SUCCEEDED(pwba->get_HWND((LONG_PTR*)&hwndWBA)) &&
(hwnd == hwndWBA))
{
hr = ViewFromWebBrowserApp(pwba, riid, ppv);
}
pwba->Release();
}
pdispWBA->Release();
}

psw->Release();
}
return hr;
}



----- Original Message -----
From: "Paul Farry"
To: "chrisg"
Sent: Sunday, March 23, 2003 6:01 PM
Subject: [CodeProject] Re: much easier/more reliable way to do this


> NOTE: This message has been sent from an unattended email box. To reply
> either visit the URL below or copy and paste the email address
> that was supplied to us below into your email client.
>
> An answer has been posted to your message on the page 'Find Target Shell
Extension':
>
> URL :
http://www.codeproject.com/useritems/findtarget.asp?msg=453682#xx453682xx
> From: Paul Farry (pfarry@coloradogroup.com.au)
>
> This call appears to be only for XP or better.
>
> Anything comparable for W2k?
>
>
>
> ---------------------------------------------------------------
> This message was created by The Code Project
> http://www.codeproject.com
>
>
>


Chris Guzak (ms)
GeneralRe: much easier/more reliable way to do this
LupinTaiwan
7:46 13 Mar '08  
For your information, "Find Target" can also be done with ShellExecute a command line as
"Explorer.exe /e,/select,C:\\Windows\\notepad.exe".

I tried and this works at WinXP. Smile
I'm not sure if it also works at W2K or earlier Windows. Sniff
Generalnot display in context menu
billhao
5:59 4 Feb '03  
I have try to register it with regsvr32 and rebuild the entire project, but it dose not display in the context? Why?

--------------------------------------
e-mail: billhao@hotmail.com
MSN Messenger: billhao@hotmail.com
http://www.minivoice.com
GeneralRe: not display in context menu
Tak
10:05 4 Feb '03  
What about rebooting your system?
GeneralRe: not display in context menu
billhao
21:24 4 Feb '03  
the same, not displayed.
I am using win2000 pro, what is your system?

--------------------------------------
e-mail: billhao@hotmail.com
MSN Messenger: billhao@hotmail.com
http://www.minivoice.com
GeneralRe: not display in context menu
Paul Farry
12:57 7 Feb '03  
Revised version with Fix included now available.
GeneralRe: not display in context menu
billhao
2:42 8 Feb '03  
Paul, Good job!

--------------------------------------
e-mail: billhao@hotmail.com
MSN Messenger: billhao@hotmail.com
http://www.minivoice.com
GeneralRe: not display in context menu
Bill Hart
17:41 26 Aug '03  
[To use the extension, either just regsvr32 it, or . . . . .]

Never having used regsvr32 before I was a little in doubt about what to do but it worked first try (actually 2nd try - had to copy "FindTarget.dll" to System32 folder) and I expect this will be a very valuable tool for me.

Thanks Paul

Bill Hart
GeneralRe: not display in context menu
Paul Farry
22:21 5 Feb '03  
I'm quite annoyed why it isn't registering.
I'm using W2k srv, and not much else.
VC6.


GeneralRe: not display in context menu
Paul Farry
4:01 7 Feb '03  
I'm sorry there was a problem with my code.. I loaded it onto another system and discovered I was incorrectly adding the classid to the registry.


GeneralRe: not display in context menu
billhao
4:18 7 Feb '03  
Any way to solve it? This function is very useful for me. I hope you can solve it. Thanks for your code.



--------------------------------------
e-mail: billhao@hotmail.com
MSN Messenger: billhao@hotmail.com
http://www.minivoice.com


Last Updated 4 Feb 2003 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010