🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.deployment
3 messages
3 total messages Started by sugi Wed, 28 Feb 2007 07:14
How to Create a Shortcut File
#61
Author: sugi
Date: Wed, 28 Feb 2007 07:14
13 lines
1120 bytes
Hi all,

I am using BCB 6. I am writing an installer code to setup
my application. During installation, I want my installation 
program to create a shortcut file, so when user click 
start menu, my application icon will be appeared. 
How to do that?

Thanks in advance.

Best regards
Sugi
Re: How to Create a Shortcut File
#62
Author: JF Jolin
Date: Wed, 28 Feb 2007 19:35
88 lines
3648 bytes
28 Feb 2007 02:14:20 -0500, sugi <trskopo@yahoo.com> wrote:

> How to do that?


// CreateLink - uses the Shell's IShellLink and IPersistFile interfaces
//              to create and store a shortcut to the specified object.
//
// Parameters:
//          LPCSTR lpszLinkTo,      - File creating shortcut for
//          LPCSTR lpszCreateLink,  - Name and path for the shortcut
//          LPCSTR lpszDesc,        - Description of Shortcut (Comment) Shows in Hint
//          LPCSTR lpszWorkDir,     - Working Directory for lpszLinkTo
//          LPCSTR lpszArguments    - Arguments for lpszLinkTo
//          int    iShow            - Window state to show 1-Normal, 3-Maximized, 7-Minimized
//                                    SW_SHOWNORMAL, SW_MAXIMIZE, SW_MINIMIZE	
//          WORD   wHotKey          - Hot key for the shortcut
//
//
HRESULT __stdcall CreateLink(LPCSTR         lpszLinkTo,
                              LPCSTR         lpszCreateLink,
                              LPCSTR         lpszDesc,
                              LPCSTR         lpszWorkDir,
                              LPCSTR         lpszArguments,
                              int            iShow,
                              WORD           wHotKey)
{
    HRESULT     hres;
    IShellLink  *psl;

    CoInitialize(NULL);

    // Get a pointer to the IShellLink interface.
    hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *) &psl);
    if (SUCCEEDED(hres)) {
       IPersistFile   *ppf;

       // The File to create a Link To  eg: the executable
       psl->SetPath(lpszLinkTo);

       // Description
       psl->SetDescription(lpszDesc);

       // Working Directory
       psl->SetWorkingDirectory(lpszWorkDir);

       // Arguments
       psl->SetArguments(lpszArguments);

       // Window State (SHOW)
       psl->SetShowCmd(iShow);

       // Hot Key / Shortcut Key
       psl->SetHotkey(wHotKey);

       // Query IShellLink for the IPersistFile interface
       // for saving the shortcut in persistent storage.
       hres = psl->QueryInterface((_GUID) IID_IPersistFile, (void **) &ppf);
       if (SUCCEEDED(hres)) {
          WCHAR  wsz[MAX_PATH];

          // IPersistFile::Save parameter's LPCOLESTR is defined as LPCWSTR for Win32 in <mapinls.h>
          // Ensure that the string is Unicode.
          MultiByteToWideChar(CP_ACP, 0, lpszCreateLink, -1, wsz, MAX_PATH);

          // Save the link by calling IPersistFile::Save.
          hres = ppf->Save(wsz, TRUE);
          ppf->Release();
       }
       psl->Release();
    }
    CoUninitialize();
    return hres;
}


Best regards

__
JF Jolin
Re: How to Create a Shortcut File
#63
Author: sugi
Date: Thu, 01 Mar 2007 07:36
14 lines
1136 bytes
"JF Jolin" <jfj@nospam.com> wrote:
>28 Feb 2007 02:14:20 -0500, sugi <trskopo@yahoo.com> wrote:
>
>> How to do that?
>
>
>// CreateLink - uses the Shell's IShellLink and IPersistFile interfaces
>//              to create and store a shortcut to the specified object.


Thank's a lots
Best Regards
Sugi
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads