Re: A Stupid Question : A DLL Wrapper

new topic     » goto parent     » topic index » view thread      » older message » newer message

Alex Chamberlain wrote:
> 
> If a DLL function accepts a string, how do I write the defining code?
> 

You have to pass a pointer to the string allocated in memory (plus a zero
at the end of the string, which allocate_string() does for you).
Assuming you had something like this in the dll:

    void foo( lpzstring * bar )

You would wrap it like this:
include machine.e
include dll.e
constant
foo_dll = open_dll( "foo.dll" ),
foo = define_c_proc( foo_dll, "foo", {C_POINTER} )

global procedure Foo( sequence bar )
    atom bar_ptr
    bar_ptr = allocate_string( bar )
    c_proc( foo, {bar_ptr})
    free( bar_ptr )
end procedure


Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu