here is my package body: wrapper for Kernel32.dll
----------------------------------------------------
PACKAGE BODY RER_UTILITY IS
/* Declare the library and function handles. */
kernel32_lhandle Ora_Ffi.Libhandletype ;
computernamea_fhandle Ora_Ffi.Funchandletype ;
/* Create the PL/SQL function that will actually */
/* invoke the foreign function. */
FUNCTION ff_computer_name(
fhandle IN Ora_Ffi.Funchandletype,
strName IN OUT VARCHAR2,
lenName IN OUT NUMBER)RETURN NUMBER;
PRAGMA interface(C, ff_computer_name, 11265);
/* Create the PL/SQL function that is defined in */
/* the package spec. This function simply */
/* passes along the arguments it receives to */
/* ff_computer_name (defined above), prepending the */
/* foreign function handle to the argument List. */
PROCEDURE rer_computer_name(
strName OUT VARCHAR2,
lenName OUT NUMBER)
IS
errNum NUMBER;
BEGIN
errNum := 1;
MESSAGE('Before' || errNum);
errNum := ff_computer_name(computernamea_fhandle, strName, lenName);
MESSAGE('After' || errNum);
EXCEPTION
WHEN OTHERS THEN
MESSAGE('Error: ' || SQLCODE || ' Desc: ' || SQLERRM);
RAISE;
END rer_computer_name;
/* Define the body of package RER_UTILITY */
BEGIN
/* Load the library. */
kernel32_lhandle := Ora_Ffi.Load_Library('C:\TEMP\', 'kernel32.dll');
/* Register the foreign function. */
computernamea_fhandle := Ora_Ffi.Register_Function(kernel32_lhandle, 'GetComputerNameA', Ora_Ffi.PASCAL_STD); -- Ora_Ffi.C_Std
/* Register the return type. */
Ora_Ffi.Register_Return(computernamea_fhandle, Ora_Ffi.C_LONG);
/* Register both parameters of function GetComputerNameA. */
Ora_Ffi.Register_Parameter(computernamea_fhandle, Ora_Ffi.C_CHAR);
Ora_Ffi.Register_Parameter(computernamea_fhandle, Ora_Ffi.C_LONG);
EXCEPTION
WHEN OTHERS THEN
MESSAGE('Error: ' || SQLCODE || ' Desc: ' || SQLERRM);
RAISE;
END; /* Package Body RER_UTILITY */
--------------------------------------------------------
VB code to call Kernel32.dll GetComputerNameA
Private Declare Function GetComputerNameAPI Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
---------------------------------------------------------
When debugging, I get kicked out of debugger with no error.
----------------------------------------------------
PACKAGE BODY RER_UTILITY IS
/* Declare the library and function handles. */
kernel32_lhandle Ora_Ffi.Libhandletype ;
computernamea_fhandle Ora_Ffi.Funchandletype ;
/* Create the PL/SQL function that will actually */
/* invoke the foreign function. */
FUNCTION ff_computer_name(
fhandle IN Ora_Ffi.Funchandletype,
strName IN OUT VARCHAR2,
lenName IN OUT NUMBER)RETURN NUMBER;
PRAGMA interface(C, ff_computer_name, 11265);
/* Create the PL/SQL function that is defined in */
/* the package spec. This function simply */
/* passes along the arguments it receives to */
/* ff_computer_name (defined above), prepending the */
/* foreign function handle to the argument List. */
PROCEDURE rer_computer_name(
strName OUT VARCHAR2,
lenName OUT NUMBER)
IS
errNum NUMBER;
BEGIN
errNum := 1;
MESSAGE('Before' || errNum);
errNum := ff_computer_name(computernamea_fhandle, strName, lenName);
MESSAGE('After' || errNum);
EXCEPTION
WHEN OTHERS THEN
MESSAGE('Error: ' || SQLCODE || ' Desc: ' || SQLERRM);
RAISE;
END rer_computer_name;
/* Define the body of package RER_UTILITY */
BEGIN
/* Load the library. */
kernel32_lhandle := Ora_Ffi.Load_Library('C:\TEMP\', 'kernel32.dll');
/* Register the foreign function. */
computernamea_fhandle := Ora_Ffi.Register_Function(kernel32_lhandle, 'GetComputerNameA', Ora_Ffi.PASCAL_STD); -- Ora_Ffi.C_Std
/* Register the return type. */
Ora_Ffi.Register_Return(computernamea_fhandle, Ora_Ffi.C_LONG);
/* Register both parameters of function GetComputerNameA. */
Ora_Ffi.Register_Parameter(computernamea_fhandle, Ora_Ffi.C_CHAR);
Ora_Ffi.Register_Parameter(computernamea_fhandle, Ora_Ffi.C_LONG);
EXCEPTION
WHEN OTHERS THEN
MESSAGE('Error: ' || SQLCODE || ' Desc: ' || SQLERRM);
RAISE;
END; /* Package Body RER_UTILITY */
--------------------------------------------------------
VB code to call Kernel32.dll GetComputerNameA
Private Declare Function GetComputerNameAPI Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
---------------------------------------------------------
When debugging, I get kicked out of debugger with no error.