Hi
My program needs to run on all versions of Windows from 95 to XP. It also needs to detect what type of OS it is running on, so I am using GetVersionEx for this.
Trouble is, my app runs fine on 98 but when I test it on XP it crashes with some kind of Access Violation.
Anyone got any ideas on how to get round this on XP?
Please help, I can't go any further with my app until I have solved this problem!
Here's my code:
#include <windows.h>
#include <iostream.h>
bool IsNTBased();
void main()
{
if ( IsNTBased() )
cout << "Is NT based\n";
else
cout << "Is not NT based\n";
}
bool IsNTBased()
// IsNTBased returns true if OS is NT based, e.g NT, 2000 or XP
// Processes: gathers OS info and checks platform id
// Returns: true if platform id indicates an NT based OS, false otherwise
{
OSVERSIONINFO * osinfo; // os version info structure pointer
GetVersionEx( osinfo ); // gather os info
// if platform identifier is NT, return true
if ( osinfo->dwPlatformId == VER_PLATFORM_WIN32_NT )
return true;
return false;
}
My program needs to run on all versions of Windows from 95 to XP. It also needs to detect what type of OS it is running on, so I am using GetVersionEx for this.
Trouble is, my app runs fine on 98 but when I test it on XP it crashes with some kind of Access Violation.
Anyone got any ideas on how to get round this on XP?
Please help, I can't go any further with my app until I have solved this problem!
Here's my code:
#include <windows.h>
#include <iostream.h>
bool IsNTBased();
void main()
{
if ( IsNTBased() )
cout << "Is NT based\n";
else
cout << "Is not NT based\n";
}
bool IsNTBased()
// IsNTBased returns true if OS is NT based, e.g NT, 2000 or XP
// Processes: gathers OS info and checks platform id
// Returns: true if platform id indicates an NT based OS, false otherwise
{
OSVERSIONINFO * osinfo; // os version info structure pointer
GetVersionEx( osinfo ); // gather os info
// if platform identifier is NT, return true
if ( osinfo->dwPlatformId == VER_PLATFORM_WIN32_NT )
return true;
return false;
}