有谁了解Windows的快捷方式文件(*.lnk)的格式?
如何提取对应的EXE文件路径与icon指向等.希望有实例(重酬)
多谢!多谢!

解决方案 »

  1.   

    把邮箱留下,我给你传个.dll过去就知道了。
      

  2.   

    例子我以前做过一个,后来删了,但主要就是用到这个.dll了。看看这个对你有没有帮助。http://expert.csdn.net/Expert/topic/1921/1921333.xml?temp=.5355799
      

  3.   

    首先多谢大哥的帮助!
    但我想做的是反向操作,想提取一个对应的EXE文件路径………
      

  4.   

    ' 我给你的那个.dll就可以做到啊.
    ' 假设要从f:\vb.lnk提取对就在的.exe文件的路径Option ExplicitPrivate Sub Command1_Click()
    Dim lnkObj As New cShellLink
    Dim ExeFile As String, WorkDir As String, ExeArgs As String
    Dim IconFile As String, IconIdx As Long, ShowCmd As Long
    lnkObj.GetShellLinkInfo "f:\vb.lnk", ExeFile, WorkDir, ExeArgs, IconFile, IconIdx, ShowCmd
    Print "Exefile = ", ExeFile
    Print "WorkDir = ", WorkDir
    Print "ExeArgs = ", ExeArgs
    Print "IconFile = ", IconFile
    Print "IconIdx = ", IconIdx
    Print "ShowCmd = ", ShowCmd
    End Sub
      

  5.   

    培培同志,给我一份研究研究行否?
    [email protected]
      

  6.   

    to pigpag(噼里啪啦):
    发过去了,也没什么新鲜的,就三个函数。  :)
      

  7.   

    我也曾用ultraedit等软件打开,看不出所以然,最好有人能介绍以下这种格式
      

  8.   

    .lnk file formatit's been a while since i've messed with that, but i dug up the following
    source code. it has been so long that i can't remember if this was the file
    i got working, so someone should test it out (i don't have time). however,
    it basically decodes the windows .lnk file format to find out what it is a
    shortcut to, and determines if that is a directory (i was going to write a
    unix type ln command using .lnk file formats.....). there are 2 files here.
    one is a c version, the other is a c++ version.... hope this helps....
                                    -donald murray
    ============================================
    c version
    ============================================
    #include <windows.h>
    #include <windowsx.h>
    #include <objbase.h>
    #include <shlobj.h>
    #include <stdio.h>
    #include <initguid.h>
    #include <string.h>
    main(int ac, char *av[])
    {
    ishelllink *psl;
    hresult hres;
    win32_find_data wfd;
    char szgotpath[max_path];
    ipersistfile *ppf;
        if (ac != 2)
    {
    printf("syntax: ln <pathname>\n");
    return 0;
    }
        hres = coinitialize(null);
    if (!succeeded(hres))
    printf("could not open the com library\n");
        hres = cocreateinstance(&clsid_shelllink, null, clsctx_inproc_server,
    &iid_ishelllink, (lpvoid *)&psl);
    if (succeeded(hres))
    {
    hres = psl->lpvtbl->queryinterface(psl, &iid_ipersistfile, &ppf);
            if (succeeded(hres))
    {
    word wsz[max_path];
                multibytetowidechar(cp_acp, 0, av[1], -1, wsz, max_path);
                hres = ppf->lpvtbl->load(ppf, wsz, stgm_read);
    if (succeeded(hres))
    {
    hres = psl->lpvtbl->resolve(psl, 0, slr_any_match);
                    if (succeeded(hres))
    {
    strcpy(szgotpath, av[1]);
                       hres = psl->lpvtbl->getpath(psl, szgotpath, max_path,
    (win32_find_data *)&wfd, slgp_shortpath );
    if (!succeeded(hres))
    printf("getpath failed!\n");
                       printf("this points to %s\n", wfd.cfilename);
    if (wfd.dwfileattributes & file_attribute_directory)
    printf("this is a directory\n");
    }
    }
    else
    printf("ipersistfile load error\n");
    ppf->lpvtbl->release(ppf);
    }
    else
    printf("queryinterface error\n");
    psl->lpvtbl->release(psl);
    }
    else
    printf("cocreateinstance error - hres = %08x\n", hres);
    return 0;
    }==================================
    c++ version
    ==================================
    #include <windowsx.h>
    #include <objbase.h>
    #include <shlobj.h>
    #include <stdio.h>
    #include <initguid.h>
    #include <stdlib.h>
    #include <io.h>
    #include <string.h>// this program should print out whether the file is a link and where it
    // points to and whether it is a directory or not.
    //
    main(int ac, char *av[])
    {
    if (ac != 2)
    {
    printf("syntax: ln <pathname>\n");
    return 0;
    }
        ishelllink *psl;                            // pointer to ishelllink i/f
    hresult hres;
    win32_find_data wfd;
    char szgotpath[max_path];
        // get pointer to the ishelllink interface.
        hres = cocreateinstance(clsid_shelllink, null, clsctx_inproc_server,
    iid_ishelllink, (lpvoid *)&psl);
        if (succeeded(hres))
    {
    // get pointer to the ipersistfile interface.
            ipersistfile *ppf;
    hres = psl->queryinterface(iid_ipersistfile, (lpvoid *)&ppf);
            if (succeeded(hres))
    {
    word wsz[max_path];
                // ensure string is unicode.
    multibytetowidechar(cp_acp, 0, av[1], -1, wsz, max_path);
                // load the shell link
    hres = ppf->load(wsz, stgm_read);
    if (succeeded(hres))
    {
    // resolve the link.
                    hres = psl->resolve(0, slr_any_match);
    //                  ^
    // using 0 instead -| of hwnd, as hwnd is only used if
    // interface needs to prompt for more information. should use
    // hwnd from current console in the long run.
                    if (succeeded(hres))
    {
    strcpy(szgotpath, av[1]);
                        hres = psl->getpath(szgotpath, max_path,
    (win32_find_data *)&wfd, slgp_shortpath );
    if (!succeeded(hres))
    printf("getpath failed!\n");
                        printf("this points to %s\n", wfd.cfilename);
    if (wfd.dwfileattributes & file_attribute_directory)
    printf("this is a directory\n");
    }
    }
    else
    printf("ipersistfile load error\n");
    ppf->release();
    }
    else
    printf("queryinterface error\n");
    psl->release();
    }
    else
    printf("cocreateinstance error - hres = %08x\n", hres);
    return 0;
    }[email protected]