Have a program in compatibility mode run another program without it

826 Views Asked by At

We have a program (let's call this one catalog) that must run in XP Compatibility mode in Windows 7 (not the VM version). However, another program (Autodesk Voloviewer) that catalog launches tends not to close at all once exited out by the user because it does not like running in XP Compatibility mode. Is there a way to launch a program from VB6 that does not inherit the compatibility mode?


I have the sneaky suspicion that advapi32.dll is going to have to get involved here, but I could be way off base.

Thanks.

1

There are 1 best solutions below

0
On

Have you tried using CreateProcess? See this knowledgebase article: http://support.microsoft.com/kb/129797.

You could try setting CREATE_NEW_PROCESS_GROUP in dwCreationFlags.

Private Const CREATE_NEW_PROCESS_GROUP As Long = &H200&

lSuccess = CreateProcess(sNull, _
                                 "Calc.exe", _
                                 ByVal 0&, _
                                 ByVal 0&, _
                                 1&, _
                                 NORMAL_PRIORITY_CLASS or CREATE_NEW_PROCESS_GROUP, _
                                 ByVal 0&, _
                                 sNull, _
                                 sInfo, _
                                 pInfo)

Or you could try resetting the environment variable __COMPAT_LAYER to empty before creating the new process, like explained here: http://support.microsoft.com/kb/286705

Public Declare Function SetEnvironmentVariable Lib "kernel32.dll" Alias "SetEnvironmentVariableA" _
    (ByVal lpName As String, ByVal lpValue As String) As Long

SetEnvironmentVariable("__COMPAT_LAYER", "")

Alternatively, you could pass your own environment settings using CreateProcess.