TCHAR str[512]= _T("%systemroot%\system32\notepad.exe");
 ::ShellExecute(NULL,_T("Open"),str,NULL,NULL,SW_SHOWNORMAL);
为什么不执行程序呢? 而换成其他全路径就能正常运行,或者用下面的也可以
 TCHAR str[512]= _T("notepad.exe");
 ::ShellExecute(NULL,_T("Open"),str,NULL,NULL,SW_SHOWNORMAL); 是因为VC识别不了  %systemroot%  么 ?
 谢谢了!!  

解决方案 »

  1.   

    "%systemroot%\\system32\\notepad.exe";
      

  2.   

    这么写不行,想得到系统目录的话用SHGetSpecialFolderPath函数
      

  3.   

    其实我是根据 .txt 搜索注册表 得到 txtfile 在通过 txtfile\Shell\Open\Command 得到的字符串 将其 赋给 str, 之后调用ShellExecute(....)
      

  4.   

    "C:\\Windows\\System32\\notepad.exe" 就可以, 但是
    "%SystemRoot%\\Sytem32\\notepand.exe" 就不执行,我估计是 shellexecute 不能识别 
    "%SystemRoot% 请高手指点!!!
      

  5.   

    需要你自己判断%%之间的字符串,用SHGetSpecialFolderPath设置对应的参数取得系统目录,然后再把后面文件名加上去合成一个实际路径
      

  6.   

    问题已经解决,感谢 neosu(CrazyNeo) !!!