🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Shortcut Information

#1598
From: Anthony
Date: Thu, 05 Jul 2007 11:43
66 lines
3061 bytes
I have a problem where if i obtain the icon location for the shortcut Adobe
reader 8.0 it causes an access violation. The icon location is:

C:\WINDOWS\Installer\{AC76BA86-7AD7-1033-7B44-A81000000003}\SC_Reader.exe

It seems to collect and save the icon location fine, but if i close the form
its running on i receive the AV and im not sure why. It also only seems to
happen to the Adobe reader shortcut, all other shortcut (icon locations)
seem to be fine.

From what i can tell it seems to be the length of the string not so much the 
information, but how can i change it to accept any length?

Can anyone point me in the right direction for what im
doing wrong?




char * pszFile;
pszFile = location.c_str();
string LnkInfo = "";

HRESULT hres;
IShellLink*   pShellLink = NULL;

//Initialise COM
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
                        IID_IShellLink, (LPVOID*)&pShellLink);

if (SUCCEEDED(hres))
{
        IPersistFile* ppf;
        // Get a pointer to the IPersistFile interface.
        hres = pShellLink->QueryInterface(IID_IPersistFile, (void**)&ppf);

        if (SUCCEEDED(hres))
        {
                WCHAR wsz[MAX_PATH];
                // Ensure that the string is Unicode.
                MultiByteToWideChar(CP_ACP, 0, pszFile, -1, wsz, MAX_PATH);
                // Load the shortcut.
                hres = ppf->Load(wsz, STGM_READ);

                if (SUCCEEDED(hres))
                {
                        HWND hwnd;
                        // Resolve the link.
                        hres = pShellLink->Resolve(hwnd, 0);

                        if (SUCCEEDED(hres))
                        {
                                int iShow;
                                unsigned short usHotKey;
                                _WIN32_FIND_DATAA pfd;
                                char buf[10];

                                         //obtain shortcut information
                                         pShellLink->GetPath(pszFile,MAX_PATH, 
&pfd, SLGP_UNCPRIORITY);
ISSUE---------->>>>      pShellLink->GetIconLocation(pszFile, MAX_PATH, 
&iShow);             <<<<----------PROBLEM LINE

//
etc....
Technical Details
Message-ID: <468cd95d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,825201284ddf9acd,start
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Anthony" <anfo@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Shortcut Information
Date: Thu, 5 Jul 2007 21:43:23 +1000
Lines: 70
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 218.215.37.88
Message-ID: <468cd95d@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1183635805 218.215.37.88 (5 Jul 2007 04:43:25 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail