[racket] OpenEventLog in ffi

From: heraklea at gmx.de (heraklea at gmx.de)
Date: Sun Nov 25 22:00:38 EST 2012

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,


Posted on the users mailing list.