 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
sam Guest
|
Posted: Wed Aug 17, 2005 1:07 pm Post subject: How Getting ptah of <C:Documents and Settingsalluser> folder |
|
|
I need to place application data on this path <C:Documents and
SettingsalluserApplication Data> for *any Windows installed*.
I used this code:
char Path[MAX_PATH+1];
SHGetSpecialFolderPath(GetActiveWindow(), Path, CSIDL_COMMON_APPDATA ,
TRUE);
but CSIDL_COMMON_APPDATA can't be used if Shell and Common Controls
Versions 5 is not installed.
So How is it possible to get this directory path <C:Documents and
SettingsalluserApplication Data> on Windows 95/98 that have Shell and
Common Controls Versions 4.70 ?
Sam
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Aug 17, 2005 6:25 pm Post subject: Re: How Getting ptah of <C:Documents and Settingsalluser> fo |
|
|
"sam" <skneife3 (AT) wanadoo (DOT) fr> wrote
| Quote: | CSIDL_COMMON_APPDATA can't be used if Shell and Common
Controls Versions 5 is not installed. So How is it possible to get this
directory path <C:Documents and SettingsalluserApplication Data
on Windows 95/98 that have Shell and Common Controls Versions 4.70 ?
|
No such folder exists on Win9x machines under 4.7x to begin with.
You will have to dynamically retreive the version of the "Shell and Common
Controls" that is actually being used by the application before deciding
when to use CSIDL_COMMON_APPDATA. You can use GetProcAddress() to retreive
a pointer to the DllGetVersion() function that Windows' DLLs export. Refer
to the following article for more details:
Shell and Common Controls Versions
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/versions.asp
Incidently, on my Win98 machine, I have
Data> and <C:WindowsApplication Data> folders available, so you may
consider using GetWindowsFolder() as an alternative to
SHGetSpecialFolderPath() when needed.
Gambit
|
|
| Back to top |
|
 |
sam Guest
|
Posted: Wed Aug 17, 2005 7:58 pm Post subject: Re: How Getting ptah of <C:Documents and Settingsalluser> fo |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message :
| Quote: | Incidently, on my Win98 machine, I have <C:WindowsAll UsersApplication
Data> and <C:WindowsApplication 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
|
|
| Back to top |
|
 |
Colin B Maharaj Guest
|
Posted: Wed Aug 17, 2005 11:43 pm Post subject: Re: How Getting ptah of <C:Documents and Settingsalluser> fo |
|
|
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:WindowsAll UsersApplication 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:
| Quote: | "Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message :
Incidently, on my Win98 machine, I have <C:WindowsAll UsersApplication
Data> and <C:WindowsApplication 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
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Aug 18, 2005 12:34 am Post subject: Re: How Getting ptah of <C:Documents and Settingsalluser> fo |
|
|
"Colin B Maharaj" <noreply (AT) myhost (DOT) com> wrote
| Quote: | 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
|
Rather than using the OS version, you should be using the Shell32.dll
version instead, since it is the one that actually implements the
SHGetSpecialFolder...() functions, and its version can be changed separately
then the OS version. CSIDL_COMMON_APPDATA can work on NT4 and Win95 if a
sufficient version of IE is installed.
| Quote: | strcat(s, "Documents and Settings\");
strcat(s, "All Users\");
strcat(s, "Application Data");
|
That path does not apply to Win9x machines. There is no "Documents and
Settings" folder for the OS to use. I mentioned the Windows folder because
that is where a lot of programs I have installed have all placed their
files, so why are you breaking out of the norm by doing something different?
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|