Re: A Stupid Question : A DLL Wrapper
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Oct 23, 2005
- 596 views
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