Re: Forms USER_EXIT / calling a DLL from Forms 4.5
From: mark tomlinson <marktoml_at_gdi.net>
Date: 1998/01/14
Message-ID: <34cc035d.160867234_at_newshost.us.oracle.com>#1/1
BEGIN
}
}
Date: 1998/01/14
Message-ID: <34cc035d.160867234_at_newshost.us.oracle.com>#1/1
On Thu, 8 Jan 1998 10:54:00 +0100, "Joachim Hasler" <jha_at_futuresoft.de> wrote:
user exists are not exactly what you want. If you do not need to maintain a transaction state with forms in your DLL - then don't use a user exit. Instead use a foriegn function. here is an example:
- ********************************************************* --
- 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,'D:\TESTCASE\MYDLL\DEBUG\MYDLL.DLL');
- Register the target function ... like WinAPI GetProcAddress()
- Note: The function name (eg. mytest) IS case sensitve in Win32 func_hndl := ora_ffi.register_function(lib_hndl,'mytest',ora_ffi.C_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;
- ********************************************************* --
- This would be the C++ code for the Win32 DLL --
- ********************************************************* --
/* ** Note: It is important that this file be compiled as a .C file ** or the exported functions -must- be wrapped so that they ** are compiled as C style functions. Failure to do this ** will result in mangled naming.*/
#include <windows.h>
extern "C"
{
int _declspec(dllexport) mytest(char* p_string);
}
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID
lpReserved)
{
if ( ul_reason_for_call == DLL_PROCESS_ATTACH ) MessageBox(NULL,"Hello","Startup",MB_OK); return 1;
}
int _declspec(dllexport) mytest(char* p_string) {
MessageBox(NULL,p_string,"Function",MB_OK); return 0;
}
--mark
>Hi everybody, > >our customer uses a self written application under Forms 4.5 (WfW 3.11). On >a button-click it is necessary to call a DLL with some parameters. This DLL >will display some information on the screen. The user will switch back to >the Forms-application by Alt+TAB. > >We have the knowledge to write DLLs in C or C++, but we don't know how to >call a DLL from a Forms-application (we have no knowledge about Forms at >all). There is a functionality called USER_EXIT. But the Oracle-sample(s) >ue_samp.mak does not work, missing files... > >Can anybody help with some sample-codes? > > > >Joachim Hasler >jha_at_futuresoft.de >Received on Wed Jan 14 1998 - 00:00:00 CET