Verknüpfung mit Parameter auf Desktop anlegen



  • Mein Programm kann mit Parametern gestartet werden. Nun möchte ich das nachdem der Benutzer Einstellungen getätigt hat und sie abgespeichert hat, das man ein Icon auf dem Desktop anlegen kann, wo das Programm mit einem Paramter verlinkt wird. Wie kann man sowas anstellen?



  • meinst du IShellLink ?



  • Jo, such mal danach. Du benötigst für sowas COM.



  • Ich habe es mir mal angeschaut, aber ich verstehe nicht wie ich es einsetzen kann. Hättet Ihr ein Beispiel für mich.



  • !!! MSDN hilft !!!

    HRESULT CreateShortCut::CreateIt(LPCSTR pszShortcutFile, LPSTR pszLink, 
      LPSTR pszDesc)
    {
        HRESULT hres;
        IShellLink* psl;
    
        // Get a pointer to the IShellLink interface.
        hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
                                IID_IShellLink, &psl);
        if (SUCCEEDED(hres))
        {
           IPersistFile* ppf;
    
           // Query IShellLink for the IPersistFile interface for 
           // saving the shell link in persistent storage.
           hres = psl->QueryInterface(IID_IPersistFile, &ppf);
           if (SUCCEEDED(hres))
           {   
             WORD wsz[MAX_PATH];
    
             // Set the path to the shell link target.
             hres = psl->SetPath(pszShortcutFile);
    
             if (!SUCCEEDED(hres))
               AfxMessageBox("SetPath failed!");
    
             // Set the description of the shell link.
             hres = psl->SetDescription(pszDesc);
    
             if (!SUCCEEDED(hres))
               AfxMessageBox("SetDescription failed!");
    
             // Ensure string is ANSI.
             MultiByteToWideChar(CP_ACP, 0, pszLink, -1, wsz, MAX_PATH);
    
             // Save the link via the IPersistFile::Save method.
             hres = ppf->Save(wsz, TRUE);
    
             // Release pointer to IPersistFile.
             ppf->Release();
           }
           // Release pointer to IShellLink.
           psl->Release();
        }
        return hres;
    }
    

Anmelden zum Antworten