<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#cccccc" text="#000000">
<tt>Hi!<br>
<br>
I want to call a function ([1]) from a dynamic library under Windows.
At first I tried to call MessageBox from "user32.dll" and failed to do
it under gambit. When I tried DrScheme and it worked fine. Here is the
source:<br>
</tt>
<blockquote><small><tt>(module dr-scheme-ffi mzscheme</tt><br>
  <tt>  </tt><br>
  <tt>  (require (lib "foreign.ss"))</tt><br>
  <tt>  (unsafe!)</tt><br>
  <tt>   (define user32.dll (ffi-lib #f))</tt><br>
  <tt>  </tt><br>
  <tt>  (define mbox</tt><br>
  <tt>    (get-ffi-obj "MessageBoxA" user32.dll</tt><br>
  <tt>                 (_fun _pointer _string _string _int -> _int)))</tt><br>
  <br>
  <tt>  (mbox #f "Message body here" "Caption here" 0)</tt><br>
  <tt>)</tt></small><br>
</blockquote>
<tt>I've searched through the whole gambit-list, but no one seems to
discuss the theme. What is the correct way to call an exported function
in a dll from gambit scheme? (Let them be at first MessageBoxA and
user32.dll).<br>
<br>
Thanks in advance,<br>
Nick.<br>
<br>
-----------------------------------------------------------<br>
<small>[1]: </small></tt><small><tt><a class="moz-txt-link-freetext" href="http://msdn2.microsoft.com/en-us/library/aa915312.aspx">http://msdn2.microsoft.com/en-us/library/aa915312.aspx</a><br>
</tt></small><tt><small>//        BOOL
ReadProcessMemory(                         <br>
//            HANDLE hProcess,                    //[in] Handle to the
process whose memory is being read.<br>
//            LPCVOID lpBaseAddress,              //[in] Pointer to the
base address in the specified process to be read.<br>
//            LPVOID lpBuffer,                    //[out] Pointer to a
buffer that receives the contents from the address space of the
specified process.<br>
//            DWORD nSize,                        //[in] Specifies the
requested number of bytes to read from the specified process.<br>
//            LPDWORD lpNumberOfBytesRead         //[out] Pointer to
the number of bytes transferred into the specified buffer.<br>
//            );<br>
</small><br>
</tt>
</body>
</html>