Home » Infrastructure » Windows » steps to call a function in VC+ dll
steps to call a function in VC+ dll [message #31207] Tue, 15 June 2004 13:30 Go to next message
Subhasini
Messages: 2
Registered: June 2004
Junior Member
Hi,

I am trying to call a VC++ function from Oracle. I have used
extern "C" in the function definition in the DLL. Can someone help me with the steps I should follow in Oracle Environment settings that should be done and the way to call the procedure
from Oracle?

thanks in advance, Subhasini
Re: steps to call a function in VC+ dll [message #31217 is a reply to message #31207] Tue, 15 June 2004 22:36 Go to previous messageGo to next message
Himanshu
Messages: 457
Registered: December 2001
Senior Member
Hi,
Use ORA_FFI package. Heres an example of code for a form.
The prototype of the function call in the dll is

int splitstr (char *str, int len, int bold, int start);

This returns a number and modifies the string passed in, hence the first parameter is a char pointer.

The first function loads the DLL into the form workspace.

Function 1:
FUNCTION Fn_Load_Function (p_func_name IN VARCHAR2)
RETURN ORA_FFI.FuncHandleType IS
l_lib ORA_FFI.LibHandleType;
l_func ORA_FFI.FuncHandleType;
BEGIN
BEGIN
l_lib := ORA_FFI.Find_Library('MYDLL.dll');
EXCEPTION
WHEN OTHERS
THEN
l_lib := ORA_FFI.Load_Library('.','MYDLL.dll');
END;
--
l_func := ORA_FFI.Register_Function(l_lib,p_func_name,ORA_FFI.C_STD);
--
Return l_func;
EXCEPTION
WHEN OTHERS
THEN
FOR c IN 1..Tool_Err.NErrors
LOOP
Message(Tool_Err.Message);
Tool_Err.Pop;
END LOOP;
END Fn_Load_Function;

And now the form function to actually make the call to the DLL.

FUNCTION Fn_Split (p_text IN OUT VARCHAR2,
p_wid IN BINARY_INTEGER,
p_att IN VARCHAR2,
p_start IN BINARY_INTEGER)
RETURN NUMBER IS
l_fn ORA_FFI.FuncHandleType;
--
FUNCTION dll_split(pFh IN ORA_FFI.funcHandleType,
str IN OUT VARCHAR2,
wid IN BINARY_INTEGER,
bld IN BINARY_INTEGER,
strt IN BINARY_INTEGER)
RETURN pls_integer;
--
PRAGMA interface( c, dll_split, 11265);
BEGIN
IF p_text IS NULL
THEN
Return NULL;
END IF;
--
l_fn := Fn_Load_Function('splitstr');
--
ORA_FFI.register_parameter(l_fn,ORA_FFI.C_CHAR_PTR );
ORA_FFI.register_parameter(l_fn,ORA_FFI.C_INT );
ORA_FFI.register_parameter(l_fn,ORA_FFI.C_INT );
ORA_FFI.register_parameter(l_fn,ORA_FFI.C_INT );
ORA_FFI.register_return(l_fn,ORA_FFI.C_INT );
--
Return dll_split(l_fn,p_text,p_wid,p_att,p_start);
END Fn_Split;

If you have a function in your library that returns nothing, you do not need to register a return value.

HTH
Himanshu
Re: steps to call a function in VC+ dll [message #668091 is a reply to message #31217] Mon, 05 February 2018 08:13 Go to previous messageGo to next message
Kokew2000
Messages: 12
Registered: December 2017
Junior Member
hi
please i have dll file wrote in c return number
status=0;
how i can read this dll file and return status value in oracle forms 6i in message
please some help if you can
thank you
Re: steps to call a function in VC+ dll [message #668092 is a reply to message #668091] Mon, 05 February 2018 08:45 Go to previous messageGo to next message
BlackSwan
Messages: 26756
Registered: January 2009
Location: SoCal
Senior Member
Kokew2000 wrote on Mon, 05 February 2018 06:13
hi
please i have dll file wrote in c return number
status=0;
how i can read this dll file and return status value in oracle forms 6i in message
please some help if you can
thank you
unwilling or incapable to use GOOGLE yourself?

http://lmgtfy.com/?q=oracle+how+to+call+dll+from+forms

https://it.toolbox.com/question/invoke-dll-from-oracle-forms-010603

Re: steps to call a function in VC+ dll [message #668136 is a reply to message #668092] Thu, 08 February 2018 08:53 Go to previous message
Kokew2000
Messages: 12
Registered: December 2017
Junior Member
hi
thanks for replay but i still cant understand the parameters and how to use it
this is my c dll code

const hasp_feature_t feature = 8;
hasp_handle_t handle = HASP_INVALID_HANDLE_VALUE;
hasp_status_t status;
unsigned char vendor_code[] =
"P+bvguFqumejqvwOmvNDruTN3d0v4O5YpN+Q3sDSPPP8EnanCZJP/9P6a3KQvkXtjZTLAUnoZSnzM0d+";
status = hasp_login(feature, vendor_code, &handle);
/* check if operation was successful */
if (status != HASP_STATUS_OK)
{
switch (status)
{
case HASP_FEATURE_NOT_FOUND:
break;
case HASP_HASP_NOT_FOUND:
break;
case HASP_OLD_DRIVER:
break;
case HASP_NO_DRIVER:
break;
case HASP_INV_VCODE:
break;
case HASP_FEATURE_TYPE_NOT_IMPL:
break;
case HASP_TMOF:
break;
case HASP_TS_DETECTED:
break;
default:
break;
}
}


if you can make it for me please help
many thanks for you again
Previous Topic: Using oracle UDT for multiple insert in 12 c
Next Topic: ora-01031: insufficient Privileges
Goto Forum:
  


Current Time: Sat Nov 28 11:37:09 CST 2020