[Haskell-cafe] Same code, system, but different arch using Win32 for reading registry.

Arjen arjenvanweelden at gmail.com
Fri Apr 7 18:08:39 UTC 2017

On Fri, 2017-04-07 at 18:51 -0100, Akos Marton wrote:
> Dear Haskellers, 
> The setup:
> Having a binary compiled on either x86 or x64 system (same
> installation, utilizing stack) in order to preserve compatibility
> against x64 systems. Actually, not to have 2 separate executable for
> each, that would be the overall goal. However it surprises me when
> running the x86 .exe utilizing Win32- package with ghc-8.0.2,
> reading out a registry key fails on x64 system with the following:
> me.exe: RegOpenKey: invalid argument (The system cannot find the file
> specified.)
> That would be fine, however the key does exists. When same code, same
> system, but the .exe built to be x64 it runs like a charm. 

32bit and 64bit Windows executables read different keys using the same
registry path. The 64bit executable can read keys from the 32bit part
of the registry, but is has to use the WOW6432Node path.
Maybe this will help: https://support.microsoft.com/en-us/help/305097/h

> A couple of question, which some of them eventually will not make
> sense, but still:
> - Can it be ghc code optimization issue?
> - but this is a runtime check in IO, if so, how?
> - Yes, I could use a built-in windows system command and parse the
> input of that; unless absolutely necessary I would not introduce
> another dependency (system package). Would love to solve it with the
> currently utilized weapons. 
> - the issue just puzzles me... I would know the answer if possible.
> - Is it more library (Win32), ghc, binary I generate, issue? 
> What library can I use to detect a system's architecture which works
> in this scenario? 
> Another thing which convoluted in the issue...
> The function, getSystemInfo :: IO SYSTEM_INFO, can read out the
> underlying architecture. When compiled on x86 and run on x64 it would
> tell me: "I am running on x86". That's failure.
> Most importantly: what is the obvious I am missing?
> Thank you for your insights! 
> Best, Akos
> Ps.: Would you/we need sample code to puzzle about I can quickly weld
> one. - not sure if necessary.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.

More information about the Haskell-Cafe mailing list