Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect whether the 3gb Switch is on or off programmatically

Tags:

c

winapi

I've been trying to determine whether the 3GB switch is on or off on the system my program is running by calling GetSystemInfo() and checking lpMaximumApplicationAddress on the SYSTEM_INFO struct.

No luck. I think I am doing something wrong.

How do you check whether the 3GB switch is on or not on Windows in C? Code is appreciated.

thanks

like image 734
Jessica Avatar asked Feb 28 '23 13:02

Jessica


1 Answers

Assuming your program is compiled as large address aware, you could simply call GlobalMemoryStatusEx and check the ullTotalVirtual field. If it's larger than 2GB, and you're running on a 32-bit system, then the 3GB flag must be turned on.

I actually have no idea how to 'properly' tell if Windows is natively 32 or 64 bit, but if you have a 32-bit process you could call IsWow64Process to see if you're running on a 64-bit OS.

This all seems a bit indirect, I know :)

like image 193
David Avatar answered Apr 27 '23 10:04

David