 |
plc.myforum.ro PLCs users www.plc.myforum.ro!
|
| View previous topic :: View next topic |
| Author |
Message |
graico Member

Joined: 17 Jun 2009 Posts: 166
|
Posted: 10/06/2015 20:51 Post subject: Using 64-bit Shortcuts from a 32-bit Application |
|
|
Using 64-bit Shortcuts from a 32-bit Application
Shell links (shortcuts) are files with a .lnk extension that store information to allow Windows Explorer to access files, folders and other objects. Applications can manipulate shortcuts using the IShellLink COM interface.
One of the problems with 32-bit applications using shortcuts on 64-bit Windows is that the target location of shortcuts which point to items in the 64-bit Program Files and System32 directories may be redirected to the 32-bit version of those directories.
This library fixes the redirection of 64-bit shortcuts for 32-bit applications. It was originally developed to allow my 8bf filter host to use shortcuts to plugins which install both the 32-bit and 64-bit versions in a subdirectory of the 64-bit Program Files. Portions of this article was adapted from my previous article on the TechNet Wiki.
The WoW64 subsystem on 64-bit Windows emulates the environment of a 32-bit operating system when executing 32-bit applications.
This includes redirecting many 64-bit environment variables (such as %ProgramFiles%) to their 32-bit equivalents. For example a shortcut to the 64-bit version of Internet Explorer would launch the 32-bit version when run from a 32-bit application.
The Wow64DisableWow64FsRedirection function can be used by 32-bit applications to temporarily disable file system redirection for the System32 directory, it does not affect redirection of Program Files.
The following example resolves the target of the Internet Explorer shortcut in the start menu, when run on a 64-bit OS the target will be resolved to the 64-bit version of Internet Explorer for both 32-bit and 64-bit applications.
| Code: | private string GetInternetExplorerPath()
{
string startMenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
string link = Path.Combine(startMenu, "Programs\\Internet Explorer.lnk");
return ShortcutResolver.Resolve(link);
} |
The Resolve method loads the shortcut and fixes the redirection of shortcut targets in the %CommonProgramFiles%, %ProgramFiles% and System32 directories when run from a 32-bit application, if the 64-bit target does not exist it returns the 32-bit path.
On Windows 7 and later the 64-bit Program Files location is exposed to 32-bit applications by the %ProgramW6432% environment variable.
On Windows Vista and earlier the 64-bit Program Files folder is resolved by removing the (x86) identifier from the 32-bit Program Files folder path.
Download code
http://www.codeproject.com/KB/shell/998952/ShortcutResolver_src.zip
http://www.codeproject.com/KB/shell/998952/ShortcutResolver_demo.zip
Read also
Wow64DisableWow64FsRedirection function
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365743%28v=vs.85%29.aspx
WOW64 Implementation Details
https://msdn.microsoft.com/en-us/library/windows/desktop/aa384274%28v=vs.85%29.aspx |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro
|