🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10892

Creating A Shortcut To A File

#10892
From: Arif Cimen
Date: Fri, 19 Mar 2004 14:56
125 lines
3570 bytes
Hi all,

I want to ask first that is there "T" class to create shortcuts..

Here codes (that I found in programmers reference );

//-----------------------------------

HRESULT CREATESHORTCUT::CreateLink_(String _pathtoObj,String 
_pathtoLink,String _description)
{
//LPCSTR lpszPathObj;
LPSTR lpszPathLink;
LPSTR lpszDesc; //static_cast<const char*>(x.data())
char lpszPathObj[255];
//lpszPathObj=static_cast<const char[]>(_pathtoObj.c_str());




lpszPathLink=_pathtoLink.c_str();
lpszDesc=_description.c_str();

HRESULT hres;
IShellLink *psl;
void **_transfer;
//const _GUID *_transfer;
//_GUID _transfer;





     // Get a pointer to the IShellLink 
interface.(void**)(void**)CLSCTX_INPROC_SERVER
     hres = CoCreateInstance((const _GUID&)CLSID_ShellLink, NULL,//here 
//the CoCreateInstance function do not succseeds Why?
         CLSCTX_ALL,(const _GUID&)IID_IShellLink,_transfer);




         psl=(IShellLink*)_transfer;
         if(hres==E_INVALIDARG)
         {
         int a=1134;

         int b=a/12;

         }
         else if(hres==REGDB_E_CLASSNOTREG)
          {
           int a=1134;

         int b=a/12;

          }
          else if(hres==E_OUTOFMEMORY)
          {
           int a=1134;

         int b=a/12;

          }
          else if(hres==E_UNEXPECTED)
          {
           int a=1134;

         int b=a/12;

          }
           else if(hres==CLASS_E_NOAGGREGATION)
          {
           int a=1134;

         int b=a/12;

          }


     if (SUCCEEDED(hres))
     {
         IPersistFile* ppf;

         // Set the path to the shortcut target, and add the
         // description.
         psl->SetPath(lpszPathObj);
//        psl->
         psl->SetDescription(lpszDesc);
//        psl->QueryInterface()
        // 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,
                 (wchar_t*)wsz, MAX_PATH);


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


};





//-----------------------------------

Also is there a simple way to create a shortcut..

Thanks to all people,

Arif
Technical Details
Message-ID: <405b09ca@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,d748d89f10da68cc,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-03-19 07:10:20 PST
Date: Fri, 19 Mar 2004 16:56:25 +0200
From: Arif Cimen <arifcimen@prowise.com.tr>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Creating A Shortcut To A File
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 212.175.60.242
Message-ID: <405b09ca@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1079708106 212.175.60.242 (19 Mar 2004 06:55:06 -0800)
Lines: 126
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail