Solved Determine if program running in XP SP3 compatibility mode

dianedebuda

New member
Member
Local time
8:49 PM
Messages
73
Is there way to tell if a program is running on Win7 in XP SP3 compatibility mode? (not VM XP Mode) Have an msaccess app where 1 of its functions only works if yes, so want to disable internal menu item to it if no. Would like to do this in VBA from within msaccess, but other examples welcome.
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Pro 64bit

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
Thanks, but what I need is to be able to look at those settings programmatically. Where are they stored? If I can get to them from within msaccess, that'd be great. If there's a way to get them using the command line and store an environmental variable or create a txt file, that'd work too.

So far, it looks like the value may be in HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\programpath. I think I've found a method to read the registry, so I may be off & running. If not, I believe there's a way to save the reg value to a text file as a backup, but syntax is tripping me up. Missing quotes?

reg save HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\C:\Program Files\Office97\Office\WINWORD.EXE d:\data\reg.txt

edit: Brink, I've use tons of your tutorials and your .reg files. Many, many thanks. What would be the contents for the .reg to add/remove this entry?
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Pro 64bit
A .reg file is basically just a text file with a renamed file extension. When you edit a .reg file, it'll open in Notepad.

If you like, once you set them how you like, you could export the Layers key below as a .reg file for a backup of your compatibility mode settings for all programs. Merging the .reg file would restore them.

HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
You may guess it by using the Windows API directly from VBA. In particular, the GetVersionEx API function does that. In the remarks section it explains that this API is affected by the current compatibility mode:

If compatibility mode is in effect, the GetVersionEx function reports the operating system as it identifies itself, which may not be the operating system that is installed. For example, if compatibility mode is in effect, GetVersionEx reports the operating system that is selected for application compatibility.

So by calling it, it returns the Windows version. But if compatibility is used, it will return the version that's indicated to be compatible, NOT the real Windows version actually used.
You can use the Declare Function statement together with a custom type for the return struct for calling this.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
Brink -
But I only want to control 2 entries under Layers, msaccess & winword. Can I not just isolate to those or do I have to do the whole Layers? What I'm thinking is that i could create a bat file for the app & force the Compat Mode before & after. I'd be calling the bat with a shortcut that avoids UAC like one of your tutorials outlined.

Maybe something like the following?

reg.exe Add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files\MyApp\Test.exe" /d "WINXPSP3"

reg.exe Delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files\MyApp\Text.exe"

The Goggled source for the delete was actually:

for %x in ("*.exe") do reg.exe Delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "%~fx"


Have no idea what the "%~fx" is.


Alejandro85 -
That looks really promising. One of those "is it a feature or a bug" deals?
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Pro 64bit
Got .reg stuff working

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\_Program Files\\Office97\\Office\\MSACCESS.EXE"="WINXPSP3"
"C:\\_Program Files\\Office97\\Office\\WINWORD.EXE"="WINXPSP3"


Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\_Program Files\\Office97\\Office\\MSACCESS.EXE"=-
"C:\\_Program Files\\Office97\\Office\\WINWORD.EXE"=-

Thanks for helping a .reg neophyte. Now onwards to GetVersionEX
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Pro 64bit
All is working. Thanks for help. Been many, many years since I've programmed Access.
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Pro 64bit
Great news. Glad we could help some. :)
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
Back
Top