0

How can I get windows build number in Haskell? I think I can use readProcess and ver, but maybe there are more clear methods.

Malyutin Egor
  • 127
  • 1
  • 10

2 Answers2

2

Is there a native C function in WinAPI that returns Windows build number?

If yes, you can easily call it from Haskell using ForeignFunctionInterface extension.

arrowd
  • 33,231
  • 8
  • 79
  • 110
1

The Win32 package seems to allow to access the build number, within the IO monad. Untested.

import System.Win32.Info.Version -- from Win32 package

main :: IO ()
main = do
   osVersionInfo <- getVersionEx
   print (dwBuildNumber osVersionInfo)
chi
  • 111,837
  • 3
  • 133
  • 218
  • Isn't it an overkill for such simple task? – Malyutin Egor Mar 10 '19 at 09:06
  • @MalyutinEgor Overkill? Why do you think that? It couldn't be much simpler than that: importing a single library and using one library function to query OS information. Further, it's also way more efficient than spawning an external process to call `ver`, and parsing the output. – chi Mar 10 '19 at 09:23