Re: How to call Windows DLL from forms 6
From: DriftWood <drift_wood_at_my-deja.com>
Date: Tue, 05 Dec 2000 17:29:06 GMT
Message-ID: <90j8kn$cns$1_at_nnrp1.deja.com>
END;
BEGIN
Date: Tue, 05 Dec 2000 17:29:06 GMT
Message-ID: <90j8kn$cns$1_at_nnrp1.deja.com>
This is the most basic sample I could create and is based on a the function MYTEST in the DLL MYDLL.DLL. The MYTEST function would be defined in the C code as:
int WINAPI MyTest (char* xyz);
- ********************************************************* --
- This would be the calling trigger's code --
- ********************************************************* --
declare
- Parameters parm1 VARCHAR2(200) := 'Something';
- Return value
rt PLS_INTEGER;
begin
rt := MyLib.MyFunc1( parm1 );
end;
- ********************************************************* --
- This would be the wrapper package header code --
- ********************************************************* --
PACKAGE MyLib IS
FUNCTION MyFunc1( parm1 IN OUT VARCHAR2 )
RETURN PLS_INTEGER;
END;
- ********************************************************* --
- This would be the wrapper package body code --
- ********************************************************* --
PACKAGE BODY MyLib IS
lib_hndl ora_ffi.libHandleType;
func_hndl ora_ffi.funcHandleType;
- Note that we always pass a function handle in as the first parameter FUNCTION i_MyFunc1( func_hndl IN ora_ffi.funcHandleType, parm1 IN OUT VARCHAR2 ) RETURN PLS_INTEGER;
- This pragma is identical (except the function name) for all ORA_FFI functions PRAGMA INTERFACE(C,i_MyFunc1,11265);
FUNCTION MyFunc1( parm1 IN OUT VARCHAR2 )
RETURN PLS_INTEGER IS rc PLS_INTEGER;
BEGIN
- Note that the function handle is the first parameter in the call rc := i_MyFunc1(func_hndl, parm1); RETURN (rc); END ;
- Load the library ... like WinAPI LoadLibrary() lib_hndl := ora_ffi.load_library(NULL,'MYDLL.DLL');
- Register the target function ... like WinAPI GetProcAddress() func_hndl := ora_ffi.register_function (lib_hndl,'MYTEST',ora_ffi.PASCAL_STD);
- Denote the parameter list ora_ffi.register_parameter(func_hndl,ORA_FFI.C_CHAR_PTR);
- Denote the return value ora_ffi.register_return(func_hndl,ORA_FFI.C_INT); END;
-- -cheers DW -------------------------------------------------------------------- "It is a kind of good deed to say well; and yet words are not deeds. -William Shakespeare" Sent via Deja.com http://www.deja.com/ Before you buy.Received on Tue Dec 05 2000 - 18:29:06 CET