2009年7月8日 星期三

octave 呼叫 DLL

/* http://www.gnu.org/software/octave/doc/interpreter/Oct_002dFiles.html#Oct_002dFiles
to compile, type
>mkoctfile calldll.cc
*/
// calldll.cc
#include "octave/oct.h"
#include "windows.h"
#include "stdio.h"
typedef void (*helloDLL)(char *in,char *out,int n);

DEFUN_DLD (calldll, args, nargout, "An example to call DLL\n")
{
HINSTANCE hDLL; // Handle to DLL
helloDLL hello;
octave_value_list OctRet;
static char ret[1024];
hDLL = LoadLibrary((LPCSTR)"Project1.dll"); // load dll
if( hDLL != NULL)
{
hello = (helloDLL) GetProcAddress(hDLL, "hello");
hello("send parameter",ret,0);
OctRet(0)="OK";
FreeLibrary(hDLL);
}
return OctRet;

}

沒有留言: