*********************************************************************
Programatically creating a shortcut
Function: (bool) CreateShortCut (LPCSTR, LPCSTR, LPCSTR) 
 bool CreateShortCut(LPCSTR lpszSourceFile,
            LPCSTR lpszDestination, 
            LPCSTR lpszDesc) 
{ 
  HRESULT     hResult    = NULL; 
  IShellLink* pShellLink = NULL; 
  bool        rc     = false;

  hResult = CoInitialize(NULL);
  // Initialize the IShellLink interface. 
    
  hResult = CoCreateInstance(CLSID_ShellLink, NULL, 
                 CLSCTX_INPROC_SERVER, IID_IShellLink, 
                 (void**) &pShellLink); 
  // Get a pointer to the IShellLink Interface

  if (SUCCEEDED(hResult)) 
  { 
    IPersistFile* ppf = NULL; 
    pShellLink->SetPath(lpszSourceFile); 
    // Set the path to the shortcut target
    
    hResult = pShellLink->SetDescription(lpszDesc); 
    // Add Description

    hResult = pShellLink->QueryInterface(IID_IPersistFile, (void**) &ppf); 
    // Query IShellLink for the IPersistFile interface for saving the
    // shortcut in persistent storage. 
 
    if (SUCCEEDED(hResult)) 
    { 
    WORD wszWideString[MAX_PATH]; 
    
    // Ensure that the string is ANSI. 
        MultiByteToWideChar(CP_ACP, 0, lpszDestination, -1,
                wszWideString, MAX_PATH); 

        hResult = ppf->Save(wszWideString, TRUE); 
        // Save the link by calling IPersistFile::Save. 
            
    ppf->Release(); 
    rc = true;
    } 
    pShellLink->Release(); 
    CoUninitialize();
    // Clean up
  } 
  return rc; 
} 
Where 
lpszSourceFile should contain the Source file for which the shourtcut has to be created.
lpszDestination Should contain the target directory and the shourt cut file name.
lpszDesc can contain any suitable description.

Ex: To Create a shortcut file named "Shortcut to SomeFile.txt.lnk" on Desktop for a file "C:\SomeFolder\SomeFile.txt" call the function as 
        CreateShortCut("C:\\SomeFolder\\SomeFile.txt",
               "C:\\Windows\\Desktop\\Shortcut to SomeFile.txt.lnk", 
               "This is a short cut to the file C:\SomeFolder\SomeFile.txt"); 
Note: The note the file name contained in lpszDestination should have a file externsion of .lnk to enable windows to recognize it as a short cut.  
*********************************************************************
