首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > Open a Folder,and select a specified file(VC++).
【标  题】:Open a Folder,and select a specified file(VC++).
【关键字】:Open,Folder,and,select,specified,file,VC++
【来  源】:http://blog.csdn.net/RonCha/archive/2006/06/08/780800.aspx

Open a Folder,and select a specified file(VC++).

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;
}

2、Use SHOpenFolderAndSelectItems Function

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;
}

 
C For Dummies(2nd Edition)- [0] Table of Contents:【上一篇】
C语言自学-1:【下一篇】
【相关文章】
  • SQL select的基本语法
  • The Provider Design Pattern and Data Access Component - III
  • Could not display home page and Memory exception
  • ACCESS and PalmSource Announce the ACCESS Linux...
  • 使 .bash_profile 文件中环境变量马上生效的命令
  • 7 Install Amavisd-new, SpamAssassin And ClamAV
  • MD File详细介绍[原转]
  • 怎样在VC++中读取INI文件[转载]
  • In Memory Data Compression and Decompression[转载]
  • svn的mysql认证例子和权限控制accessfile
  • 【随机文章】
  • 操作系统常见问题:进入Win9x出现两次询问密码的窗口
  • Linux的系统性能监测参数获取
  • 电子政务建设的“四四八七”
  • 实例讲解-整合iBATIS和Spring在WEB开发中的应用
  • 让Dreamweaver 3.0 识别.php3 扩展名的文件
  • VS2005中两个有用的源代码管理选项
  • ThinkPad的开机出错代码(Post Error Code)速查
  • linux下不能正常测试邮箱服务的解决方法
  • 而今迈步重头越-复习基本算法 之 希尔排序
  • Effective C++之20
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.