<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
&nbsp;&nbsp; GHC 6.4's support for Win32 is definitely broken. However, I've been
experimenting with implementing a wrapper using FFI, and that has
proven to be reasonably easy. The only gotchas:<br>
<br>
1- You have to run ghc --make with the extra -lGdi32, -lUser32, etc...
switches.<br>
2- You can't use something like ghc -e:Main.main Main.hs to run Win32
programs. As soon as you are passing function pointers around
(WindowProcs and the like) it just won't work because of the stub.c
files.<br>
3- Safely managing function pointers can be tricky, because FuncPtr has
to be explicitly deallocated or else it will leak.<br>
4- If you don't want to have the console window, you have to add the
-optl-mwindows switch to the command line (hopefully, it'll be
documented at some point) and refrain from ever writing anything out to
stdout or stderr. If you want to be able to write stuff out (so that
you can see it by ommitting the switch) then do something like this: <br>
<br>
---8&lt;---------------------------<br>
initGUI = catch (putStr " \b" &gt;&gt; hFlush stdout) $ \_ -&gt; do<br>
&nbsp;&nbsp;&nbsp; fd &lt;- open "nul" 2 0<br>
&nbsp;&nbsp;&nbsp; dup2 fd 0<br>
&nbsp;&nbsp;&nbsp; dup2 fd 1<br>
&nbsp;&nbsp;&nbsp; dup2 fd 2<br>
&nbsp;&nbsp;&nbsp; return ()<br>
<br>
open fname oflag pmode = withCString fname $ \c_fname -&gt; c_open
c_fname oflag pmode<br>
<br>
foreign import ccall unsafe "HsBase.h __hscore_open" c_open :: CString
-&gt; CInt -&gt; CInt -&gt; IO CInt<br>
foreign import ccall unsafe "HsBase.h dup2" dup2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :: CInt
-&gt; CInt -&gt; IO CInt<br>
---8&lt;---------------------------<br>
<br>
&nbsp;&nbsp; and then call initGUI from your main.<br>
<br>
&nbsp;&nbsp; All very platform/compiler dependent, of course, so use with good
judgement.<br>
<br>
JCAB<br>
<br>
Neil Mitchell wrote:
<blockquote cite="mid404396ef05091102201d4d0ea8@mail.gmail.com"
 type="cite">
  <pre wrap="">Hi,

The CVS version of Hugs for Windows has a module
System.Win32.Registry, along with quite a few other windows modules.

I'm not sure if the last stable releases have these features in or not.

Thanks

Neil

On 9/11/05, Brian McQueen <a class="moz-txt-link-rfc2396E" href="mailto:mcqueenorama@gmail.com">&lt;mcqueenorama@gmail.com&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">How can I use Haskell to do general Windows programming, like you
would be able to do if you were using one of those Windows IDEs:

*moving data between windows apps
*gaining access to windows registry
*in general, access to the available Windows APIs

I'm sure folks must be writing Windows apps in Haskell somewhere.  How
do I get started?

Brian McQueen
_______________________________________________
Haskell-Cafe mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a>

    </pre>
  </blockquote>
  <pre wrap=""><!---->_______________________________________________
Haskell-Cafe mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a>

  </pre>
</blockquote>
</body>
</html>