[racket] OpenEventLog in ffi

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Nov 25 23:00:57 EST 2012

You want `OpenEventLogW'. (In C, `OpenEventLog' is a macro that expands
to either `OpenEventLogW' or `OpenEventLogA'.)

At Mon, 26 Nov 2012 04:00:38 +0100, heraklea at gmx.de wrote:
> Hello friends,
> 
> I try to write the OpenEventLog:
> HANDLE OpenEventLog(
>   _In_  LPCTSTR lpUNCServerName,
>   _In_  LPCTSTR lpSourceName
> );
> 
> in Racket ffi:
> 
> #lang racket
> (require ffi/com
>          ffi/unsafe
>          ffi/unsafe/define
>          ffi/winapi)
> 
> (define _HANDLE (_cpointer/null 'HANDLE))
> (define advapi-dll (and (eq? (system-type) 'windows)
>                         (ffi-lib "Advapi32.dll")))
> 
> (define-ffi-definer define-advapi advapi-dll
>   #:default-make-fail make-not-available)
> 
> (define PROVIDER_NAME  "Application")
> (define MACHINENAME "MyMachine")
> (define-advapi OpenEventLog (_fun #:abi winapi
>                                   _string/utf-16
>                                   _string/utf-16
>                                   -> (r : _HANDLE)))
> 
> After all, eval this: >(OpenEventLog MACHINENAME PROVIDER_NAME)
> brings an error:
> OpenEventLog: implementation not found; arguments: "MyMachine" "Application"
> 
> These steps in Racket which I defined above are programmed as I understand it.. 
> 
> So is there any misunderstanding in usind the ffi.
> Or do I something wrong?
> 
> The type understanding is a little bit confusing.
> 
> 
> The first questions that comes to my mind is:
> 
> What is a const char*, LPCTSTR, BSTR, or HANDLE etc
> There are some instructions on creating these types ( as far as I can found it) 
> but how to use it in Racket?
> Ok back to my problem.
> 
> I would like to write the openeventlog, closeevntlog, readeventlog etc 
> functions but I fail at openeventlog.
> 
> Could anybody hold my hands?;O)
> 
> Yours,
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.