假设安装了A.exe文件,而我只知道文件名称A.exe,如果通过这个A.exe名称找到这个exe文件所在路径?
举例》你安装了photoshop,通过photoshop名称,找到photoshop.exe的完全路径。
谢谢!!!!!!!1

解决方案 »

  1.   

    CString ExpandShortcut(CString &inFile)
    {
        CString outFile = ""; CoInitialize(NULL);
    // Make sure we have a path
    ASSERT(inFile != _T(""));

    IShellLink* psl;
    HRESULT hres;
    LPTSTR lpsz = inFile.GetBuffer(MAX_PATH);

    // Create instance for shell link
    hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
    IID_IShellLink, (LPVOID*) &psl);
    if (SUCCEEDED(hres))
    {
    // Get a pointer to the persist file interface
    IPersistFile* ppf;
    hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*) &ppf);
    if (SUCCEEDED(hres))
    {
    // Make sure it's ANSI
    WORD wsz[MAX_PATH];
    ::MultiByteToWideChar(CP_ACP, 0, lpsz, -1, wsz, MAX_PATH);

    // Load shortcut
    hres = ppf->Load(wsz, STGM_READ);
    if (SUCCEEDED(hres)) {
                    WIN32_FIND_DATA wfd;
                    // find the path from that
                    HRESULT hres = psl->GetPath(outFile.GetBuffer(MAX_PATH), 
    MAX_PATH,
    &wfd, 
    SLGP_UNCPRIORITY);

                    outFile.ReleaseBuffer();
    }
    ppf->Release();
    }
    psl->Release();
    }

        inFile.ReleaseBuffer();
    CoUninitialize();

        // if this fails, outFile == ""
    return outFile;
    }
      

  2.   

    不是根据快捷方式找,假如你只知道我机器上安装了photoshop,那么一定存在photoshop.exe文件吧,你如何根据这个photoshop.exe名称来找到photoshop.exe的全路径。不知大家明白没有?
      

  3.   

    注册表怎么搜啊, taianmonkey 朋友的方法我试过了,很好,就是有点慢!先谢谢了!!!!
      

  4.   

    在你安装应用程序时,应用程序一般会在注册表定义几个键值,你先找到键值,再根据键值去读。或者根据GUID值去找。