我已知道如何获得windows目录和程序运行所在目录,现在想知道如何用语言实现向桌面添加快捷方式,即让程序运行一次就在桌面上添加了程序快捷方式(我这里是指在程序里,而不是用任何制作安装的工具如installshield等

解决方案 »

  1.   

    在www.vckbase.net里好象有相关文档
      

  2.   

    HRESULT CreateLink(LPCSTR lpszPathObj,
          LPSTR lpszPathLink,
          LPSTR lpszDesc)
      HRESULT hres;
      IShellLink* psl;
      CoInitialize(NULL);
      // Get a pointer to the IShellLink interface.
      hres = CoCreateInstance(CLSID_ShellLink, NULL,
        CLSCTX_INPROC_SERVER,
        IID_IShellLink,
        (void **)&psl);
      if (SUCCEEDED(hres))
      {
        IPersistFile* ppf;
        // Set the path to the shortcut target and add the
        // description.
        psl->SetPath(lpszPathObj);
        psl->SetDescription(lpszDesc);
        // Query IShellLink for the IPersistFile interface for saving the
        // shortcut in persistent storage.
      hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
          if (SUCCEEDED(hres))
          {
        WORD wsz[MAX_PATH]; // Ensure that the string is ANSI.
        MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1,wsz, MAX_PATH);
        // Save the link by calling IPersistFile::Save.
        hres = ppf->Save(wsz, TRUE);
          ppf->Release();
          }
      psl->Release();
      }
      return hres;
      

  3.   

    http://sanjianxia.myrice.com/vc/vc72.htm