Solved

how can i make a shortcut in the desktop?

Posted on 2004-10-30
184 Views
Last Modified: 2013-11-20
i want to make a shortcut in the desktop of my exe..

0
Question by:xxtigerxx
    3 Comments
     
    LVL 86

    Accepted Solution

    by:
    Check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/shortcuts/shortcut.asp ("Shell Links"). It basically is

    // CreateLink - uses the Shell's IShellLink and IPersistFile interfaces
    //              to create and store a shortcut to the specified object.
    //
    // Returns the result of calling the member functions of the interfaces.
    //
    // Parameters:
    // lpszPathObj  - address of a buffer containing the path of the object.
    // lpszPathLink - address of a buffer containing the path where the
    //                Shell link is to be stored.
    // lpszDesc     - address of a buffer containing the description of the
    //                Shell link.

    HRESULT CreateLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc)
    {
        HRESULT hres;
        IShellLink* psl;
     
        // Get a pointer to the IShellLink interface.
        hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
                                IID_IShellLink, (LPVOID*)&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, (LPVOID*)&ppf);
     
            if (SUCCEEDED(hres))
            {
                WCHAR wsz[MAX_PATH];
     
                // Ensure that the string is Unicode.
                MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH);
                      
                // TODO: Check return value from MultiByteWideChar to ensure
                         success.
     
                // Save the link by calling IPersistFile::Save.
                hres = ppf->Save(wsz, TRUE);
                ppf->Release();
            }
            psl->Release();
        }
        return hres;
    }

    A class to encapsulate this can be found at http://www.codeproject.com/shell/CShortcut.asp ("CShortcut ")

    0
     
    LVL 2

    Expert Comment

    by:Ruskialt
    With right mouse button, drag your exe file to the desktop. Select "Create Shortcuts Here".

    You can also right click the desktop and select New->Shortcut, then browse to your exe.
    0
     
    LVL 6

    Expert Comment

    by:Amritpal Singh
    hi
    have a look at the following link

    http://www.funducode.com/comstuff/com/com_4.asp
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
    Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now