🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

SHGetSpecialFolderLocation still not functioning on Win 95!

#15223
From: Zack
Date: Sat, 12 Jul 2003 19:21
126 lines
4798 bytes
Please help - I have been struggling with this issue for some time now and
am just about ready to kill myself.

I need to get the locations of special folders on all Windows platforms.  So
I am using the SHGetSpecialFolderLocation and SHGetPathFromIDList functions
which are supported on win 95 and up.

This works fine on 2K, but when I test on 95 I have troubles.  Mainly - the
call fails and GetLastError reports that the specified procedure could not
be found.  This is despite the fact that I have done a TDUMP of the
shell32.dll on the 95 machine and I can see the functions there, I even
tried dynamically loading shell32 myself and using loadlibrary and
getprocaddress, both of which succeed - but the actual call fails with the
same stupid error !

Here is the simpler version of the code (sorry about any formatting
problems):

char PathStr [MAX_PATH+1] = {0};
LPITEMIDLIST pidl = NULL;

if( SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_SYSTEM, &pidl)) )
{
    if( SHGetPathFromIDList(pidl, PathStr) )
    {
        // use it here...
        CoTaskMemFree(pidl);
    }
    else
    {
        MessageDlg("SHGetPathFromIDList Failed.", mtWarning,
TMsgDlgButtons() << mbOK, 0);
        ProcessErrorMessage(); // displays GetLastError message
    }
}
else
{
    MessageDlg("SHGetSpecialFolderLocation Failed", mtWarning,
TMsgDlgButtons() << mbOK, 0);
    ProcessErrorMessage(); // displays GetLastError message
}

On Windows 95 this should work (as documented) but it does not - the first
call fails with the last error being "the specified procedure could not be
found"

So I tried to manually load it myself with this code :

typedef HRESULT ptrGETFOLDFUNC(HWND hwndOwner, int nFolder, LPITEMIDLIST
*ppidl);
typedef BOOL ptrGETPATHID(LPCITEMIDLIST pidl, LPTSTR pszPath);

...

char PathStr [MAX_PATH+1] = {0};
LPITEMIDLIST pidl = NULL;

HANDLE dllHandle = LoadLibrary("Shell32.dll");


if(dllHandle)
{
    // SUCCESS!
    MessageDlg("Got Handle", mtWarning, TMsgDlgButtons() << mbOK, 0);

    ptrGETFOLDFUNC * ptrFolderLoc ;
    ptrFolderLoc = (ptrGETFOLDFUNC*)GetProcAddress(dllHandle,
"SHGetSpecialFolderLocation");

    if (ptrFolderLoc)
    {
        //SUCCESS!
        MessageDlg("Got SHGetSpecialFolderLocation", mtWarning,
TMsgDlgButtons() << mbOK, 0);

        ptrGETPATHID * ptrPathID ;
        ptrPathID = (ptrGETPATHID*)GetProcAddress(dllHandle,
"SHGetPathFromIDList");

        if (ptrPathID)
        {
            // SUCCESS !
            MessageDlg("Got SHGetPathFromIDList", mtWarning,
TMsgDlgButtons() << mbOK, 0);

            // NEXT LINE FAILS - even though the function is correct!

            if( SUCCEEDED(ptrFolderLoc(Handle, CSIDL_SYSTEM, &pidl)))
            {
                if( ptrPathID(pidl, PathStr) )
                {
                    // use it here
                    CoTaskMemFree(pidl);
                }
                else
                {
                    MessageDlg("SHGetPathFromIDList Failed.", mtWarning,
TMsgDlgButtons() << mbOK, 0);
                    ProcessErrorMessage(); // displays GetLastError message
                }
            }
            else
            {
                MessageDlg("SHGetSpecialFolderLocation Failed", mtWarning,
TMsgDlgButtons() << mbOK, 0);
                ProcessErrorMessage(); // displays GetLastError message
            }
    }
}
else
{
    MessageDlg("Failed to get dll handle", mtWarning, TMsgDlgButtons() <<
mbOK, 0);
    ProcessErrorMessage(); // displays GetLastError message
}



So - as you can see in the second code snippet - even though I can
dynamically load the dll no problem and and get the address of the function
no problem - the actual call to it still fails on Win 95 with the same
bloody error "the specified procedure could not be found"!!!!

Please help me - I am going mad!!!

Zack.
Technical Details
Message-ID: <3f105f7e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,556d3fb208abaeda,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-12 12:27:46 PST
From: "Zack" <a@bv.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: SHGetSpecialFolderLocation still not functioning on Win 95!
Date: Sat, 12 Jul 2003 12:21:38 -0700
Lines: 130
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 24.84.53.212
Message-ID: <3f105f7e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1058037630 24.84.53.212 (12 Jul 2003 12:20:30 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail