Discussion:
ProgramFiles folder for Win7
(too old to reply)
P E Schoen
2010-11-09 20:26:21 UTC
Permalink
I have an application which was originally developed using Borland Delphi 4
Pro and tested for XP. I rewrote it so that it works on Vista, but now many
customers will be using Win7 (and I now have a Win7 Home Premium 64 bit
machine). I see that there is a new environment variable for 32 bit x86
program files and I want to make sure the program gets installed properly.
In my code I have the following:

CSIDL_COMMON_APPDATA = $0023; { All Users\Application Data }
CSIDL_SYSTEM = $0025; { Windows\System32 }
CSIDL_COMMON_DOCUMENTS = $002E; { All Users\Documents }
CSIDL_PROGRAM_FILES = $0026;

ProgramFolder := GetSystemFolder(CSIDL_PROGRAM_FILES);

I am using Inno Setup which has a constant which points to the ProgramFiles
folder for the installation. I have not yet tried to install my program on
my system but one of my customers has done so with questionable success. I
can test for the OS and use the 32 bit program files folder if Win7 is
detected. I already do this (which was needed for the BDE) as follows:

procedure TfmReclData.FormCreate(Sender: TObject);
const WIN2000 = 5.0;
WINXP = 5.1;
WINVISTA = 6.0;
WIN7 = 6.1;
var VersionInfo: OSVERSIONINFO;
Version: Real;
begin
VersionInfo.dwOSVersionInfoSize := sizeof (OSVERSIONINFO);
getVersionEx( VersionInfo );
Version := VersionInfo.dwMajorVersion + VersionInfo.dwMinorVersion/10;
if (Version >= WINVISTA) and (Session <> nil) then
Session.NetFileDir := ProgramDataFolder;
if Session <> nil then begin
fmDebug.AddDebugItem( 'FormCreate: OS Version: ' + Format( '%3.1f',
[Version] );
fmDebug.AddDebugItem( 'FormCreate: NetFileDir: ' +
Session.NetFileDir ); end;

Does anyone know of any issues that I need to be concerned about for Win7?
There is a new environment variable for 32 bit programs which is
CSIDL_PROGRAM_FILESx86, but of course it is not defined in D4.

Also, I wonder if the 32 bit version of Win7 has the ProgramFiles(x86)
folder or the usual ProgramFiles?

I have also posted this on the Microsoft Tech Forum but no response so far).

Thanks!
Jamie
2010-11-09 21:23:34 UTC
Permalink
Post by P E Schoen
I have an application which was originally developed using Borland
Delphi 4 Pro and tested for XP. I rewrote it so that it works on Vista,
but now many customers will be using Win7 (and I now have a Win7 Home
Premium 64 bit machine). I see that there is a new environment variable
for 32 bit x86 program files and I want to make sure the program gets
CSIDL_COMMON_APPDATA = $0023; { All Users\Application Data }
CSIDL_SYSTEM = $0025; { Windows\System32 }
CSIDL_COMMON_DOCUMENTS = $002E; { All Users\Documents }
CSIDL_PROGRAM_FILES = $0026;
ProgramFolder := GetSystemFolder(CSIDL_PROGRAM_FILES);
I am using Inno Setup which has a constant which points to the
ProgramFiles folder for the installation. I have not yet tried to
install my program on my system but one of my customers has done so with
questionable success. I can test for the OS and use the 32 bit program
files folder if Win7 is detected. I already do this (which was needed
procedure TfmReclData.FormCreate(Sender: TObject);
const WIN2000 = 5.0;
WINXP = 5.1;
WINVISTA = 6.0;
WIN7 = 6.1;
var VersionInfo: OSVERSIONINFO;
Version: Real;
begin
VersionInfo.dwOSVersionInfoSize := sizeof (OSVERSIONINFO);
getVersionEx( VersionInfo );
Version := VersionInfo.dwMajorVersion + VersionInfo.dwMinorVersion/10;
if (Version >= WINVISTA) and (Session <> nil) then
Session.NetFileDir := ProgramDataFolder;
if Session <> nil then begin
fmDebug.AddDebugItem( 'FormCreate: OS Version: ' + Format( '%3.1f',
[Version] );
fmDebug.AddDebugItem( 'FormCreate: NetFileDir: ' +
Session.NetFileDir ); end;
Does anyone know of any issues that I need to be concerned about for
Win7? There is a new environment variable for 32 bit programs which is
CSIDL_PROGRAM_FILESx86, but of course it is not defined in D4.
Also, I wonder if the 32 bit version of Win7 has the ProgramFiles(x86)
folder or the usual ProgramFiles?
I have also posted this on the Microsoft Tech Forum but no response so far).
Thanks!
32 bit code gets installed so that the 32 bit interface see it's properly.
I don't think you even need to test for the OS version.

The new environment variable i am sure is only for 64 bit code to
find the 32 bit folder location.. If you are to use this in your 32 bit
code,
you must treat this as possible failure of existence.. You could thus
test to see if it exist and if so, get the actual folder the 64 bit OS
is using..

You must remember that WIn7 has the WOW directory or something like
that for the win32 code.. I believe that is where this new environment
variable will start pointing too.!



But then again, I could be wrong, won't be the first time,..


P.S.
Win 7 , unless you have the PRO version(xp mode), will not install
apps that use a 16 bit installer or has any 16 bit code somewhere in
files... This most likely also means DOS thingys..
P E Schoen
2010-11-10 20:44:24 UTC
Permalink
Post by Jamie
32 bit code gets installed so that the 32 bit interface see it's properly.
I don't think you even need to test for the OS version.
The new environment variable i am sure is only for 64 bit code to find
the 32 bit folder location.. If you are to use this in your 32 bit code,
you must treat this as possible failure of existence.. You could thus
test to see if it exist and if so, get the actual folder the 64 bit OS
is using..
You must remember that WIn7 has the WOW directory or something like that
for the win32 code.. I believe that is where this new environment
variable will start pointing too.!
But then again, I could be wrong, won't be the first time,..
P.S.
Win 7 , unless you have the PRO version(xp mode), will not install apps
that use a 16 bit installer or has any 16 bit code somewhere in
files... This most likely also means DOS thingys..
Thanks for the ideas. I'll post again when I know more. This post is partly
to test my new "Windows Live Mail" newsreader which came with my new Win7
machine. It was not copying news posts to the Sent Items folder (and it also
will not show fixed width fonts for news). I know, get a better newsreader.
But it's convenient to use just the one program!

Paul
a***@aol.com
2010-11-11 12:33:49 UTC
Permalink
This post might be inappropriate. Click to display it.
Robert Wolfe
2012-05-17 15:49:26 UTC
Permalink
Post by P E Schoen
Does anyone know of any issues that I need to be concerned about for Win7?
There is a new environment variable for 32 bit programs which is
CSIDL_PROGRAM_FILESx86, but of course it is not defined in D4.
Also, I wonder if the 32 bit version of Win7 has the ProgramFiles(x86)
folder or the usual ProgramFiles?
The (x86) program files directory shows up only in the 64-bit versions of Windows Vista, 2008 Server and 7.
Dietmar Braun
2012-05-17 15:01:15 UTC
Permalink
Post by Robert Wolfe
The (x86) program files directory shows up only in the 64-bit versions
of Windows Vista, 2008 Server and 7.

Usually, on these platforms, 32-bit software installs in "x86", e.g. "C:
\Program Files (x86)\", and the 64-bit versions install in e.g. "C:
\Program Files\" (without the "x86"!)

Dietmar
Jamie
2012-05-17 21:45:37 UTC
Permalink
Post by Robert Wolfe
Post by P E Schoen
Does anyone know of any issues that I need to be concerned about for Win7?
There is a new environment variable for 32 bit programs which is
CSIDL_PROGRAM_FILESx86, but of course it is not defined in D4.
Also, I wonder if the 32 bit version of Win7 has the ProgramFiles(x86)
folder or the usual ProgramFiles?
The (x86) program files directory shows up only in the 64-bit versions of Windows Vista, 2008 Server and 7.
The best thing to do is to use the "ShGetspecialFolderLocation" with
in your 32 bit programs, it should return the actual name of the 32 bit
programs folder for you. And if you're on a 64 bit Os, you should get
the (x86) name in there some where.

I do think the CDIDL_PROGRAM_FILESx86 flag was more intended for 64 bit
programs to find out where the 32 bit programs folder is. Since older
existing 32 bit programs do not know anything about this flag, it's
logical to assume that using the shxxxxxx method to get the name will
continue to work.

Jamie

Loading...