Tuesday, November 29, 2011

Re: libcall and dll problem

You can get and store the handoe of library to variable in vimscript.

-------- mylib.dll --------
char buf[256];
char*
libopen(char* libname) {
  sprintf(buf, "%p", dlopen(libname, RTLD_LAZY)); // If win, use LoadLibrary()
  return buf;
}

libclose(char* p) {
  void* handle = NULL;
  sscanf("%p", &handle);
  dlclose(handle); // If win, use FreeLibrary()
}

libcall(char* handle, char* func, char* arg) {
  void* handle = NULL;
  sscanf("%p", &handle);
  // do it something  
}
-------- mylib.vim --------
function! libopen(libname)
  return libcall("mylib.dll", "libopen", a:libname)
endfunction

function! libclose(handle)
  call libcall("mylib.dll", "libclose", a:handle)
endfunction

let handle = libopen("otherlib.dll")
" do it something.
call libclose(handle)
------------------------

If you want to call Windows APIs simplely, below may become your help. :)

https://github.com/mattn/libcallex-vim


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment