Launching Shell Links (LNKs) from WOW64

后端 未结 4 622
执念已碎
执念已碎 2021-01-14 13:33

Our 32-Bit application launches Windows LNK files (Shell Links) via ShellExecute. When it tries to \"launch\" a link to a 64-Bit binary (such as the \"Internet Explorer (64-

相关标签:
4条回答
  • 2021-01-14 14:03

    Reading this article from Raymond Chen I don't think what you're asking is possible. I would still consider making a small "trampoline" application, who's only job was to launch the given application/link, and compiling a different one for use on 32bit and 64bit systems. Either that or build two versions of your application, a 32bit and 64bit one.

    0 讨论(0)
  • Anytime you here something is impossible on a computer, think again... The key is to utilize the c:\windows\sysnative\ path to shut off the redirection.

    Here is very simple code that will do what you want:

    #include <windows.h>
    #include <ShellAPI.h>
    #include <stdio.h>
    
    int main(int iArgc, const char *pArgv[])
    {
        ShellExecute(NULL, L"open", L"C:\\windows\\sysnative\\..\\..\\Program Files\\Internet Explorer\\iexplore.exe", NULL, NULL, SW_SHOWNORMAL);
        BOOL bIAmWow64 = FALSE;
        IsWow64Process(GetCurrentProcess(), &bIAmWow64);
        printf("I am a wow64 process: %hs\n", bIAmWow64 ? "Yes": "No");
        return 0;
    }
    

    I hope that is helpful.

    0 讨论(0)
  • 2021-01-14 14:05

    You could spawn an explorer.exe process which calls on the LNK.

    Is there a particular reason you can't compile your program as a 64bit application?

    0 讨论(0)
  • 2021-01-14 14:21

    Andrew: I gave it a shot, and the sysnative folder does not do anything that Wow64DisableWow64FsRedirection doesn't already do. The problem is that ShellExecute mistakenly assumes that the link is pointing to %programfiles(x86)%, when it is in fact pointing to %programfiles% (Even when there is no such file in %programfiles(x86)%).

    Opening 64bit programs already works perfectly fine. It's .lnk files pointing to the %programfiles% directory that are the problem.

    0 讨论(0)
提交回复
热议问题