🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

IShellLink Problem

#9630
From: Martin C
Date: Fri, 25 Jun 2004 02:42
48 lines
2467 bytes
Hi all,

I am trying to run the following code in a loop to search for all broken
shortcuts on my Desktop/ Startmenu ( I mean to detect if a shortcut is
pointing to a file that was moved, deleted...etc), although everytime I
start searching I receive an AV just after the function detect and validate
the first 2 shortcuts...so can someone help me please and let me know what
exactly I am missing here.

BR

   CoInitialize( NULL );
   IShellLink* shell_link;
   HRESULT result = CoCreateInstance( (_GUID) CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_HANDLER, (_GUID)
IID_IShellLink, (void**) &shell_link );

    if (SUCCEEDED(result))
    {IPersistFile* persist_file;
      result = shell_link->QueryInterface( (_GUID)IID_IPersistFile, (void**)
&persist_file );
      if (SUCCEEDED(result))
      {
        //File below is just an example....

         AnsiString ShortcutFilePath =
"C:\\AOL_Quick_Reference_Guide.pdf.lnk";
         wchar_t wShortcutFilePath[MAX_PATH];
         ShortcutFilePath.WideChar(wShortcutFilePath, MAX_PATH);

        if (SUCCEEDED(persist_file->Load(wShortcutFilePath, STGM_READ)))
        {  if(SUCCEEDED(shell_link->Resolve(NULL, SLR_ANY_MATCH)))
           {  WIN32_FIND_DATA wfd;
              char filename[MAX_PATH];
               if (SUCCEEDED(shell_link->GetPath(filename, MAX_PATH,&wfd,
SLGP_UNCPRIORITY)))
              { ShowMessage(filename);
              }
           }
        }
         persist_file->Release();
      }
      shell_link->Release();
    }
    else
    { ShowMessage("FAILED ON SHELL LINK");
    }
   CoUninitialize();
Technical Details
Message-ID: <40db7522@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!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,299ab1f0afec8bf3,start
X-Google-Attributes: gid10cc67,public
From: "Martin C" <martincplus@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: IShellLink Problem
Date: Thu, 24 Jun 2004 20:42:58 -0600
Lines: 50
Organization: V Safe
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 81.10.4.238
Message-ID: <40db7522@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1088124194 81.10.4.238 (24 Jun 2004 17:43:14 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail