Determine if program running in XP SP3 compatibility mode


  1. Posts : 73
    Windows 7 Pro 64bit
       #1

    Determine if program running in XP SP3 compatibility mode


    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


  2. Posts : 72,051
    64-bit Windows 11 Pro for Workstations
       #2

    Hello Diane,

    You could check the program's compatibility mode settings using OPTION ONE in the tutorial below to see what it's currently set at if using compatibility mode. :)

    Compatibility Mode
      My Computer


  3. Posts : 73
    Windows 7 Pro 64bit
    Thread Starter
       #3

    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


  4. Posts : 72,051
    64-bit Windows 11 Pro for Workstations
       #4

    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


  5. Posts : 2,468
    Windows 7 Ultimate x64
       #5

    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


  6. Posts : 73
    Windows 7 Pro 64bit
    Thread Starter
       #6

    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


  7. Posts : 73
    Windows 7 Pro 64bit
    Thread Starter
       #7

    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


  8. Posts : 73
    Windows 7 Pro 64bit
    Thread Starter
       #8

    All is working. Thanks for help. Been many, many years since I've programmed Access.
      My Computer


  9. Posts : 72,051
    64-bit Windows 11 Pro for Workstations
       #9

    Great news. Glad we could help some. :)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:14.
Find Us