🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How Getting ptah of <C:\Documents and Settings\alluser> folder

#5458
From: Colin B Maharaj
Date: Wed, 17 Aug 2005 23:43
74 lines
3436 bytes
Hi Sam/Remy here is what I did. I looked for the version of the O/S if
a "better NT" version exists, I use CSIDL_COMMON_APPDATA else I use 
CSIDL_PROGRAMS and get the drive letter and manually build the path.
With respect to <C:\Windows\All Users\Application Data> I just hate 
putting stuff in a sub directory in Windows in 9x/me so I did not do 
that but I put it in the same drive of WINDOWS like this.
Hope it helps...

//---------------------------------------------------------------
// Application path for App Data All Users for all O/Ss returned
// in char * s
//---------------------------------------------------------------

#include <shlobj.h>

  void AllUsersAppData(char * s)
  {
     LPMALLOC      ShellMalloc;
     LPITEMIDLIST  DesktopPidl;
     char Dir[MAX_PATH];

     OSVERSIONINFO osv;
     osv.dwOSVersionInfoSize = sizeof(osv);
     GetVersionEx(&osv);
     bool BetterNT   = (osv.dwMajorVersion >= 5);

     if(FAILED(SHGetMalloc(&ShellMalloc))) return;
     int nFolder;

     if (BetterNT == true)  nFolder = CSIDL_COMMON_APPDATA;
     else                   nFolder = CSIDL_PROGRAMS;
     if(FAILED(SHGetSpecialFolderLocation(NULL, nFolder,  &DesktopPidl)))
     {
       *s = NULL;
     }

     if(!SHGetPathFromIDList(DesktopPidl, Dir))
     {
         ShellMalloc->Free(DesktopPidl);
         ShellMalloc->Release();
     }

     ShellMalloc->Free(DesktopPidl);
     ShellMalloc->Release();
     strcpy(s, Dir);
     if (BetterNT == false) // 9x/me maybe NT
     {
       s[3] = NULL;
       strcat(s, "Documents and Settings\\");
       strcat(s, "All Users\\");
       strcat(s, "Application Data");
     }
  }

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

sam wrote:
> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message :
> 
> 
>>Incidently, on my Win98 machine, I have <C:\Windows\All Users\Application
>>Data> and <C:\Windows\Application Data> folders available, so you may
>>consider using GetWindowsFolder() as an alternative to
>>SHGetSpecialFolderPath() when needed.
> 
> 
> You mean GetWindowsDirectory() in place of GetWindowsFolder() for placing 
> application data for Windows 9.x and ME?
> Thanks for help.
> 
> Sam
> 
> 
Technical Details
Message-ID: <4303cbab@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!news.germany.com!newsfeed.kamp.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43033672@newsgroups.borland.com> <430381af$1@newsgroups.borland.com> <430396e0@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6638340ca3c38f1c
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 17 Aug 2005 19:43:57 -0400
From: Colin B Maharaj <noreply@myhost.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a4) Gecko/20040927
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: How Getting ptah of <C:\Documents and Settings\alluser> folder
References: <43033672@newsgroups.borland.com> <430381af$1@newsgroups.borland.com> <430396e0@newsgroups.borland.com>
In-Reply-To: <430396e0@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 200.108.29.95
Message-ID: <4303cbab@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1124322219 200.108.29.95 (17 Aug 2005 16:43:39 -0700)
Lines: 74
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!news.germany.com!newsfeed.kamp.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail