1、invoke explorer.exe with agrument
like this :
explorer.exe /e,/select,c:\NTDETECT.COM
//FileName :the file you want to locate.
void CGotGotoFile(CString FileName)
{
CString szLink;
szLink.Format(" /e,/select,%s",FileName);
ShellExecute(NULL,"open","explorer.exe",(LPCTSTR)szLink,NULL,true);
return;
}
HRESULT SHOpenFolderAndSelectItems(
LPCITEMIDLIST pidlFolder, UINT cidl, LPCITEMIDLIST *apidl, DWORD dwFlags );
void GotoFile(CString FileName)
{
OLECHAR path[MAX_PATH]={0};
ITEMIDLIST *idl;
//Initializes the COM library on the current thread
CoInitialize(NULL);
MultiByteToWideChar(CP_ACP,NULL,FileName,-1,path,MAX_PATH);
SHParseDisplayName(path,NULL,&idl,NULL,NULL);
SHOpenFolderAndSelectItems(idl,NULL,NULL,NULL);
//Closes the COM library on the current thread,
CoUninitialize();
return;
}