1

Is there any way to access 64bit exe-files with a 32bit app? I am using Delphi 2009 (upgrade to XE2 is not possible, moneywise, right now)

I am making this launcher, and when running it on win7 64bit, it doesn't pickup the right icons for 64bit apps, and ShellExecute doesn't seem to work either with those apps. Now, all these apps are in "C:\program files" which suggests that this is a WOW64 thing. I have googled various ways to temporarily disable wow-redirection, but none seems to work.

Warren P
  • 65,725
  • 40
  • 181
  • 316
Lars Bargmann
  • 142
  • 1
  • 7
  • `C:\Program Files` is not redirected. No WOW64 here. If you are using `%ProgramFiles%` or getting that folder with CSIDL then you will pick up the 32 bit folder, `C:\Program Files (x86)`. What is the exact path used by your program? – David Heffernan Jul 11 '12 at 06:57
  • There is no "exact" path. I am picking up shortcuts in a dir for the launcher, and retrieving icons from those. These are also being ShellExecute'd... but neither part works, if the shortcuts are pointing towards 64bit apps... – Lars Bargmann Jul 11 '12 at 07:03
  • There has to be a path somewhere. The system can't find a file without. Until you show us some code and give us some details, we can only speculate. – David Heffernan Jul 11 '12 at 08:02
  • "C:\Program Files\Oracle\VirtualBox\VirtualBox.exe", "C:\Program Files\SpeedProject\SpeedCommander 12\SpeedCommander.exe" are 2 of the targets in some of the shortcuts... There's nothing strange about those at all, to my eyes... but neither icon-extracting or shellexecute works on those shortcuts... :-( – Lars Bargmann Jul 11 '12 at 08:18
  • Ok, it gets stranger... "C:\Program Files\CCleaner\CCleaner64.exe" works... ???? – Lars Bargmann Jul 11 '12 at 08:19
  • 3
    How can we help you if you refuse to tell us what you are doing? Show code. Give details of failure modes, error messages, error codes etc. Or solve the problem by yourself. – David Heffernan Jul 11 '12 at 08:22
  • I am really not refusing to show anything, but it is so simple, that there's nothing to show really... I do a ShellExecute on a shortcut (with the mentioned targets). ShellExecute returns 3 (The specified path was not found) which I dont understand at all... – Lars Bargmann Jul 11 '12 at 08:30
  • ShellExecute(0, '', PChar(FFilename), '', '', SW_SHOWNORMAL); I tried various things, like using GetDesktopWindow and 'open', but with the same results. FFilename is the path+name of a .lnk file – Lars Bargmann Jul 11 '12 at 08:34
  • @David, he is not the only one with this problem: https://forums.embarcadero.com/thread.jspa?messageID=396324 and maybe related: http://stackoverflow.com/a/8837838/800214 – whosrdaddy Jul 11 '12 at 08:38
  • @LarsBargmann, does it make a difference running with UAC on or off? – whosrdaddy Jul 11 '12 at 08:42
  • Nope, UAC makes no difference at all, sadly. – Lars Bargmann Jul 11 '12 at 08:53
  • 1
    Please put the code in the question. It's not readable in the comments, and who's going to trawl through the comments anyway. Click on the edit button and edit the question. – David Heffernan Jul 11 '12 at 09:16
  • 1
    The questions look like they are related: http://stackoverflow.com/questions/386715/launching-shell-links-lnks-from-wow64 http://stackoverflow.com/questions/3124332/wow64-woes-lnk-shortcuts and I think the problem is that the short cut does not contain C:\Program Files, but in fact contains `%ProgramFiles%`. The shell probably expands that when it displays it to you but if you use the shell API to interrogate the .lnk file I bet you'll see an indirection like this. And actually that's exactly what I posited in my first comment to this question. – David Heffernan Jul 11 '12 at 09:21
  • As for the solution, I'd say that you'd be best off with a 64 bit app here. – David Heffernan Jul 11 '12 at 09:21
  • Yup, I can reproduce what you describe by creating a shortcut that uses `%ProgramFiles%`. Whoever created that shortcut took a very poor decision and frankly that is the fundamental problem here. You are simply going to have to work around it. – David Heffernan Jul 11 '12 at 09:30
  • I think it's a little deeper than that, though. I just tried creating shortcuts, using windows explorer, and those fail too. I haven't checked if windows itself makes the shortcuts point to %programfiles%, because I honestly wouldn't know how. I've never worked with shortcuts, other than right-clicking them and selecting "properties" :-) – Lars Bargmann Jul 11 '12 at 09:39
  • Ok, shortcuts are pretty simple to work with, apparantly. I just tried resolving the shortcuts, using jclShell, and they (as you suspect) return "Program Files (x86)" as their path. I do not see "%ProgamFiles%" though, but get the substituted path, though... – Lars Bargmann Jul 11 '12 at 09:49
  • Yeah, I can repro all of that. I must say, I have no idea why the shell is turning `C:\Program Files` into `C:\Program Files (x86)`. That makes absolutely no sense to me at all. I'd just use a 64 bit launcher. An AnyCPU C# app would do the job nicely. – David Heffernan Jul 11 '12 at 09:53
  • It is really strange, but thanks for all your help... for now, I made a very dirty hack (check if file is shortcut, resolve shortcut, if file doesn't exists then remove ' (x86)' from path... Extremely dirty, but it actually works... for now... – Lars Bargmann Jul 11 '12 at 10:07

0 Answers0