need help Identifying what OS in on a PC programmatically

I am currently working on a project to get an existing 32 bit app to work in windows xp and windows 7. Currently the program works in XP is called us a script file that checks a folder in C:\Program files\ . since it is a 32 bit program it will be installed in c:\program files (x86) on the windows 7 machine. the same script will no longer in window 7. my idea is to write a program/ script that can identify the version of windows that is running on the machine . once it is determined run the program using the points to the correct program files folder .

Thank you for your help.
Have you looked at SHGetFolderPath? https://msdn.microsoft.com/en-us/library/bb762181%28v=VS.85%29.aspx

1
2
3
4
5
6
7
8
9
10
11
TCHAR szPath[MAX_PATH];

if(SUCCEEDED(SHGetFolderPath(NULL, 
                             CSIDL_PROGRAM_FILES, 
                             NULL, 
                             0, 
                             szPath))) 
{
    PathAppend(szPath, TEXT("New Doc.txt"));
    HANDLE hFile = CreateFile(szPath, ...);
}
closed account (E0p9LyTq)
Win 7 32-bit uses just the "Program Files" folder for programs, 64-bit uses the "Program Files (x86)" folder for 32-bit programs. So you might want to determine if the program is running under 32 or 64 bit Windows first, using the "IsWow64Process" function.

https://msdn.microsoft.com/en-us/library/ms684139%28VS.85%29.aspx
Topic archived. No new replies allowed.