PRAGMA INTERFACE

Migrating from forms 4.5 to 9i and currently using PRAGMA INTERFACE to link to a c library within a dll. This will not work in the new environment. Does anyone know of an alternative that can be used?

If this is your problem ,then,perhaps you should use ora_ffi package to call c funtions in dll..works fine

Similar Messages

  • Convert ORA_FFI to WEBUTIL_C_API to print locally

    I am trying to figure out how to convert this package to WEBUTIL_C_API to be able to print to a users local printer (EPSON slip printer)... ANY help would be appreciated...
    PACKAGE EPSON_SLIP_PRINTER_INTERFACE IS
    * This package provides functions to interact with the EPSON
    * TM-U295 slip printers.
    * The OPEN_PRINTER function must be called to obtain a printer ID.
    * This printer ID can then be used when calling other functions
    * that require a printer to be specified.
    * NOTE that the printer ID is only valid within the same thread
    * that called the OPEN_PRINTER function.
    * Brendan Rickey 2004-JAN-09
    -- AVAILABLE PRINTERS
    CHEQUE_PRINTER     VARCHAR2(50) := 'Generic / Text Only droite';
    INVOICE_PRINTER     VARCHAR2(50) := 'Generic / Text Only left';
    -- ERROR CODES
    -- Some of the provided functions return a NUMBER value that may hold
    -- an error code (negative number).
    -- These are the possible error codes:
    SUCCESS                    NUMBER := 0;     --no error
    ERR_TYPE               NUMBER := -10;     --parameter type error
    ERR_OPENED               NUMBER := -20; --printer already opened
    ERR_NO_PRINTER     NUMBER := -30;     --the printer driver does not exist
    ERR_NO_TARGET          NUMBER := -40;     --no printer found (could of off, faulty, unsupported)
    ERR_NO_MEMORY          NUMBER := -50;     --insufficient memory
    ERR_HANDLE               NUMBER := -60;     --invalid printer ID
    ERR_TIMEOUT               NUMBER := -70;     --time out error
    ERR_ACCESS               NUMBER := -80;     --cannot read/write to printer (printing in progress)
    ERR_PARAM               NUMBER := -90;     --parameter error
    ERR_OFFLINE               NUMBER := -110;     --printer was opened in offline state.  Status must be changed to online.
    ERR_NOT_EPSON          NUMBER := -120;     --printer is not an EPSON printer
    * INITIALIZE
    * Initializes the interface between Forms and the EPSON library (call before any other function in the package).
    * Returns:
    * TRUE if the library is registered successfully,
    * FALSE otherwise (library not found etc...)
    function INITIALIZE return BOOLEAN;
    * OPEN_PRINTER
    * Obtains a handle on the specified EPSON slip printer (either CHEQUE_PRINTER or INVOICE_PRINTER).
    * Returns:
    *           a printer ID for the specified printer (greater than 0)
    *           an error code on failure (less than 0):
    * ERR_TYPE, ERR_OPENED, ERR_NO_PRINTER, ERR_NO_TARGET, ERR_NO_MEMORY, ERR_PARAM
    function OPEN_PRINTER (p_printer_name IN VARCHAR2) return NUMBER;
    * CLOSE_PRINTER
    * Releases the handle on the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE on failure
    function CLOSE_PRINTER (p_printer_id IN NUMBER) return NUMBER;
    * IS_PAPER_OUT
    * Tests if there is no paper in the printer.
    * Returns:
    *           1 if there is no paper in the printer, 0 if paper is in the printer
    *           ERR_HANDLE or ERR_PARAM on failure.
    function IS_PAPER_OUT (p_printer_id IN NUMBER) return NUMBER;
    * PRINT_TEXT
    * Prints the specified text to the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE, ERR_ACCESS, ERR_OFFLINE, ERR_NOT_EPSON, or ERR_PARAM on failure.
    function PRINT_TEXT (p_printer_id IN NUMBER, p_text IN VARCHAR2) return NUMBER;
    * RELEASE_PAPER
    * Performs the Release function on the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE, ERR_ACCESS, ERR_OFFLINE, ERR_NOT_EPSON, or ERR_PARAM on failure.
    function RELEASE_PAPER (p_printer_id IN NUMBER) return NUMBER;
    /* PRIVATE FUNCTIONS
    function BiOpenMonPrinter(arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER;
    function BiCloseMonPrinter(arg0 in PLS_INTEGER)
    return PLS_INTEGER;
    function BiGetStatus(arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER;
    function BiDirectIO(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER;
    function BiDirectIOEx(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER;
    END;
    PACKAGE BODY EPSON_SLIP_PRINTER_INTERFACE IS
    v_msg_b VARCHAR2(20);
    v_EPSON_LIBRARY_OK BOOLEAN:= FALSE;
    --ORA_FFI function handles and library handle
    lh_EpsStmApi ora_ffi.libHandleType;                    --DLL library handle
    fh_BiOpenMonPrinter ora_ffi.funcHandleType;          --DLL function handle
    fh_BiCloseMonPrinter ora_ffi.funcHandleType;     --DLL function handle
    fh_BiGetStatus ora_ffi.funcHandleType;               --DLL function handle
    fh_BiDirectIO ora_ffi.funcHandleType;               --DLL function handle
    fh_BiDirectIOEx ora_ffi.funcHandleType;               --DLL function handle
    --constant
    ASB_SLIP_BOF     PLS_INTEGER := 4*power(16,5);     --BOF printer status flag 0x00400000
    c_release_code      CHAR(2) := CHR(27)||CHR(113);     --ESC+q, to release the paper
    -------PRIVATE FUNCTIONS--------
    * Brendan Rickey 2004-JAN-09
    * The following are functions that are required to interface with the
    * EPSON StatusAPI DLL (C library) though ORA_FFI.
    * The following describes the DLL functions that are made available
    * through this ORA_FFI implementation:
    Function Purpose
    BiOpenMonPrinter Get a handle on a printer.
    Parameters
    p_Type --int: 1 if p_Name is a port, 2 if a printer name.
    ,p_Name --varchar2: the port of printer name to open.
    Return printer identifier number (>0) on success, < 0 on failure.
    BiCloseMonPrinter Close the monitor on the printer.
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    Return 0 on success, < 0 on failure.
    BiGetStatus Returns the status of the printer.
    Parameters     
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_Status OUT --long: The status of the printer (use AND bitwise operator to test for statuses).
    Return 0 on success, < 0 on failure.
    BiDirectIO Sends data to and Reads data from the printer. Use BiDirectIOEx if more that 255 chars are to be written/read.
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_WriteLen --short: The length of the command/data being sent to the printer (max 255).
    ,p_WriteCmd --varchar2: The command/data to send to the printer.
    ,p_ReadLen --short: The length of the data to be read from the printer (max 255)
    (Use 0 if no data is to be read).
    ,p_ReadBuff OUT --varchar2: The buffer where the the data read from the printer is stored.
    ,p_Timeout --long: write/read time out in msecs.
    ,p_NullTerminate --short: 0 => reading of data from printer is performed until time out or length of p_ReadLen is reached.
    1 => reading is finished at thepoint when a NULL is received from the printer. ReadLen must have a value.
    Return 0 on success, < 0 on failure.
    BiDirectIOEx Sends data to and Reads data from the printer (handles larger quantities of write/read data).
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_WriteLen --long: The length of the command/data being sent to the printer.
    ,p_WriteCmd --varchar2: The command/data to send to the printer.
    ,p_ReadLen --long: The length of the data to be read from the printer (Use 0 if no data is to be read).
    ,p_ReadBuff OUT --varchar2: The buffer where the the data read from the printer is stored.
    ,p_Timeout --long: write/read time out in msecs.
    ,p_NullTerminate --short: 0 => reading of data from printer is performed until time out or length of p_ReadLen is reached.
    1 => reading is finished at thepoint when a NULL is received from the printer. ReadLen must have a value.
    ,p_Option --short: 0 => prevents Automatic Status Back (ASB) during execution of this function (as does BiDirectIO).
    1 => does not disable Automatic Status Back (ASB).
    Return 0 on success, < 0 on failure.
    function icd_BiOpenMonPrinter(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER;
    pragma interface(c, icd_BiOpenMonPrinter, 11265);
    function BiOpenMonPrinter(arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER is
    begin
    return(icd_BiOpenMonPrinter(fh_BiOpenMonPrinter,
    arg0,
    arg1));
    end;
    function icd_BiCloseMonPrinter(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiCloseMonPrinter, 11265);
    function BiCloseMonPrinter(arg0 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiCloseMonPrinter(fh_BiCloseMonPrinter,
    arg0));
    end;
    function icd_BiGetStatus(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiGetStatus, 11265);
    function BiGetStatus(arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiGetStatus(fh_BiGetStatus,
    arg0,
    arg1));
    end;
    function icd_BiDirectIO(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiDirectIO, 11265);
    function BiDirectIO(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiDirectIO(fh_BiDirectIO,
    arg0,
    arg1,
    arg2,
    arg3,
    arg4,
    arg5,
    arg6));
    end;
    function icd_BiDirectIOEx(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiDirectIOEx, 11265);
    function BiDirectIOEx(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiDirectIOEx(fh_BiDirectIOEx,
    arg0,
    arg1,
    arg2,
    arg3,
    arg4,
    arg5,
    arg6,
    arg7));
    end;
    --------PUBLIC FUNCTIONS--------
    function INITIALIZE return BOOLEAN IS
    BEGIN
    --When this is the first package function called, code in the package's
    --body is executed and sets v_EPSON_LIBRARY_OK.
    RETURN v_EPSON_LIBRARY_OK;
    END;
    function OPEN_PRINTER (p_printer_name IN VARCHAR2) return NUMBER IS
         v_printer                    PLS_INTEGER;
         v_printer_name     VARCHAR2(50) := p_printer_name;
         v_name_type           PLS_INTEGER := 2; --use printer Name to specify printer     
    BEGIN
         /* Open a monitor for the printer */
         v_printer := BiOpenMonPrinter(v_name_type,v_printer_name);
         RETURN v_printer;
    END;
    function CLOSE_PRINTER (p_printer_id IN NUMBER) return NUMBER IS
    v_return PLS_INTEGER;
    BEGIN
    /* CLOSE the printer monitor */
         v_return := BiCloseMonPrinter(p_printer_id);
         RETURN v_return;
    END;
    function IS_PAPER_OUT (p_printer_id IN NUMBER) return NUMBER IS
         v_return          PLS_INTEGER;
         v_status          PLS_INTEGER := -123456;
    BEGIN
         /* Test if paper is in the printer by first getting the status (a binary integer) */
         v_return := BiGetStatus(p_printer_id,v_status);
         IF v_return <> 0 THEN
              RETURN v_return;
         ELSE
         --Test for BOF status flag
         IF WIN_API_BITOP.BITWISE_AND(v_status,ASB_SLIP_BOF) = ASB_SLIP_BOF THEN
              RETURN 1; --paper out
         ELSE
              RETURN 0; --paper in
         END IF;
         END IF;
    END;
    function PRINT_TEXT (p_printer_id IN NUMBER, p_text IN VARCHAR2) return NUMBER IS
    v_return          PLS_INTEGER;
    v_text               VARCHAR2(2000) := p_text;
    v_text_len          PLS_INTEGER;                    --number of characters to be printed
    v_read_len      PLS_INTEGER := 0;               --number of characters to be read from the printer
    v_read_buff      VARCHAR2(255) := NULL;          --not used: holds characters read from the printer
    v_timeout      PLS_INTEGER := 1000;          --not used: amount of time to wait for response (msecs)
         v_nullTerm          PLS_INTEGER := 0;               --not used: 0 means read until reached v_read_len or v_timeout
         -- 1 means read until NULL received from printer
         v_option          PLS_INTEGER := 0;           --0 means do not answer other requests while printing
                                                                --1 means do not stop answering other requests while printing
    BEGIN
         --Get the number of chars to be printed and then print.
         v_text_len := length(p_text);
         v_return := BiDirectIOEx(p_printer_id,
         v_text_len,
         v_text,
         v_read_len,
         v_read_buff,
         v_timeout,
         v_nullTerm,
         v_option);
         --Ignore timeout(-70) errors, otherwise return error
         IF v_return = -70 THEN
              v_return := 0;     
         END IF;
         RETURN v_return;
    END;
    function RELEASE_PAPER (p_printer_id IN NUMBER) return NUMBER IS
    BEGIN
    /* Release the paper by sending the release escape code to the printer */
         RETURN PRINT_TEXT(p_printer_id, c_release_code);
    END;
    -----END OF FUNCTION IMPLEMENTATIONS-----
    BEGIN
    * Load the EPSON printer driver's StatusAPI library.
    * Create an ORA_FFI interface to the library by doing the following for each desired function:
    *          1- Create a handle on the function,
    *          2- Register the return value,
    *          3- Register the arguments/parameters in the correct order.
    lh_EpsStmApi := ora_ffi.load_library('', 'EpsStmApi.DLL');
    IF Ora_Ffi.Is_Null_Ptr(lh_EpsStmApi) THEN
         AFC_MESSAGES('I','MAIN-0020','E',v_msg_b);
         v_EPSON_LIBRARY_OK := FALSE;
    ELSE
    fh_BiOpenMonPrinter := ora_ffi.register_function(lh_EpsStmApi, 'BiOpenMonPrinter', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiOpenMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiOpenMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiOpenMonPrinter, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    fh_BiCloseMonPrinter := ora_ffi.register_function(lh_EpsStmApi, 'BiCloseMonPrinter', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiCloseMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiCloseMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    fh_BiGetStatus := ora_ffi.register_function(lh_EpsStmApi, 'BiGetStatus', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiGetStatus, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiGetStatus, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiGetStatus, ora_ffi.c_long_ptr, ora_ffi.pls_pls_integer);
    fh_BiDirectIO := ora_ffi.register_function(lh_EpsStmApi, 'BiDirectIO', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiDirectIO, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short_ptr, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    fh_BiDirectIOEx := ora_ffi.register_function(lh_EpsStmApi, 'BiDirectIOEx', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiDirectIOEx, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long_ptr, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    v_EPSON_LIBRARY_OK := TRUE;
    END IF;
    EXCEPTION
         WHEN OTHERS THEN
              AFC_MESSAGES('I','MAIN-0021','E',v_msg_b);
              v_EPSON_LIBRARY_OK := FALSE;
    END;

    Hi Duncan,
    Thanks for the response. Beyond the problem you pointed out I found that the "open server" command is requiring a window handle parameter, even though it isn't used by the program. I talked with Oracle Support and it turns out that even if the window handle isn't used, it's existence makes it not work with the current version of webutil.
    The program I am working with also has a COM interface, so I decided to back up and redo the interface using webutil OLE2. I've got it working now, just a little more polishing to do.
    Thanks again for the help.
    Mark

  • Error 420 "Can't call builtin routines remotely" while compiling a proc

    I get the message above when I try to compile a Forms procedure with a call to specific functions in the DBMS_UTILITY package. I am using Forms 10.1.2.2.0 and 10g DB (10.2.0.4.0). I want to trace the PL/SQL path that my Forms application is taking and be able to report the line number of the failure when an exception is thrown. I am able to call some routines within the DBMS_UTILITY package, but not any of them that have "pragma interface (C, format_error_stack);" in the code. These include format_call_stack, format_error_stack, and format_error_backtrace; all of which I would like to use. I've tried creating my own DB package function to act as a wrapper; this allows me to compile the form, but the call to the function form my exception handler returns null. These are really useful functions, but I do need to be able to access the functionality from within Forms. Does anyone have a solution/workaround for this problem. Note, this is similar to the question in Link:[ http://forums.oracle.com/forums/thread.jspa?messageID=504922��]
    Thanks JK.

    Nope, that does not work. See my first post above. I've tried using a wrapper, and whilst this allows my forms procedure to compile and my form to run, the wrapper procedure is returning null. Here's some code that may help to explain where I'm at. In the form, I've got -
    DECLARE
        l_bt VARCHAR2(2000); -- BackTrace
    BEGIN
        JEK_Raise_Exception; -- This is a DB procedure
    EXCEPTION
       WHEN OTHERS THEN
          l_bt := KEYOWNER.Backtrace.generate_backtrace;
          message('l_bt = '||l_bt); pause;
    END;-- Then a DB procedure that just generates an exception
    CREATE OR REPLACE PROCEDURE JEK_Raise_Exception IS
    BEGIN
       RAISE too_many_rows;
    END;-- and the function from my Backtrace Package to return the backtrace data.
       FUNCTION generate_backtrace
           RETURN VARCHAR2
       IS
          l_bt      VARCHAR2(2000);
       BEGIN
           l_bt := DBMS_UTILITY.format_error_backtrace;
           RETURN l_bt;  -- In my testing so far this has been NULL!!!
       END;

  • WebUtil_c_Api problem

    I´m trying to execute the following C function:
    extern "C" __declspec( dllexport ) int add(int* value1, int* value2);
    So I have make the folling package:
    PACKAGE BODY calculator IS
         add_func webutil_c_api.FunctionHandle;
         add_func_parameters webutil_c_api.ParameterList;
         add_param1 webutil_c_api.ParameterHandle;
         add_param2 webutil_c_api.ParameterHandle;
         add_return PLS_INTEGER;     
         FUNCTION i_dll_add(add_func IN webutil_c_api.FunctionHandle, value1 IN OUT NOCOPY PLS_INTEGER,
                   value2 IN OUT NOCOPY PLS_INTEGER)
                   RETURN PLS_INTEGER;
         PRAGMA INTERFACE (c, i_dll_add, 11265);
         FUNCTION dll_add (value1 IN OUT NOCOPY PLS_INTEGER, value2 IN OUT NOCOPY PLS_INTEGER)
              RETURN PLS_INTEGER IS
              BEGIN
                   RETURN i_dll_add(add_func, value1, value2);
    END dll_add;
              add_func := webutil_c_api.register_function('Calculator_ws.dll', 'add');
              add_func_parameters := webutil_c_api.create_parameter_list;           
              add_param1 := webutil_c_api.add_parameter(add_func_parameters, webutil_c_api.C_INT_PTR, webutil_c_api.PARAM_INOUT, 0);
              add_param2 := webutil_c_api.add_parameter(add_func_parameters, webutil_c_api.C_INT_PTR, webutil_c_api.PARAM_INOUT, 1);
              add_return := webutil_c_api.Invoke_Int('Calculator_ws.dll', 'add', add_func_parameters);           
              webutil_c_api.Destroy_Parameter_List(add_func_parameters);
              webutil_c_api.Deregister_Function(add_func);           
    END calculator;
    But when I execute the FUNCTION it doesn't work. Does anyone which could be the problem?
    Thank you.

    Look again at your code - It seems to me this has been converted from some ORA_FFI code am I correct??
    If you are calling the dll_add function then this is in turn calling i_dll_add, and that is calling to a DLL loaded on the server side (that's the pragma interface bit) and not touching WebUtil or the client side at all.
    So rip out the i_dll_add spec and body and move all the webutil code calls into dll_add where they will actually be called.

  • Error on "webutil_c_api.invoke_int"

    Hello,
    i'm testing a DLL that was used in Oracle Forms 6i using ORA_FFI.
    the function that i'm testing it on Oracle 10g is :
    Function LS100_Open (hwnd in out pls_integer,
    Hinst in out pls_integer,
    Type_com in char) return pls_integer
    The Code in Oracle 10g is :
    declare
    ret_val      pls_integer;
    hwnd          pls_integer;     
    handle          pls_integer;     
    typ_com          varchar2(1):= 'S';
    f_handle      webutil_c_api.FunctionHandle;
    args          webutil_c_api.ParameterList;
    param1          webutil_c_api.ParameterHandle;
    param2          webutil_c_api.ParameterHandle;
    param3          webutil_c_api.ParameterHandle;
    begin
    f_handle := webutil_c_api.register_function('Ls100.dll','LS100_Open');
    args := webutil_c_api.create_parameter_list;
    param1 := webutil_c_api.add_parameter(args,webutil_c_api.c_int,webutil_c_api.param_out,hwnd);
    param2 := webutil_c_api.add_parameter(args,webutil_c_api.c_int,webutil_c_api.param_out,handle);
    param3 := webutil_c_api.add_parameter(args,webutil_c_api.c_char,webutil_c_api.param_in,typ_com,1);
    ret_val     := webutil_c_api.invoke_int('Ls100.dll','LS100_Open',args);
    WEBUTIL_C_API.Destroy_Parameter_List(args);
    WEBUTIL_C_API.Deregister_Function(f_handle);
    end;
    when i execute this code the following error appears:
    "WUL-910 Invoking the function failed: java.lang.IllegalArgumentException: unrecognized argument type"
    Is there anything wrong in my code ???

    hi,
    the function in dll is:
    -- pll in 6i ---
    LS100_lhandle ORA_FFI.LIBHANDLETYPE;
    LS100_Open_fhandle ORA_FFI.FUNCHANDLETYPE;
    FUNCTION ff_LS100_Open (LS100_Open_fhandle ORA_FFI.FUNCHANDLETYPE,
    hWnd IN OUT PLS_INTEGER,
    Hinst IN OUT PLS_INTEGER,
    Type_com IN CHAR) RETURN PLS_INTEGER;
    PRAGMA interface (C, ff_LS100_Open, 11265);
    FUNCTION LS100_Open (hWnd IN OUT PLS_INTEGER, --not a pointer
    Hinst IN OUT PLS_INTEGER, -- not a pointer
    Type_com IN CHAR) -- not a pointer
    RETURN PLS_INTEGER IS
    BEGIN
    RETURN( FF_LS100_Open( LS100_Open_fhandle, hWnd, Hinst, Type_com));
    END; /* function LS100_Open() */
    and in the documentation of the function in the library is defined as :
    LS100_Open
    #include "LS100.h"
    Result API LS100_Open (HWND      hwnd,
    HANDLE      Hinst,
    CHAR      Type_com);
    Description
    Open a connection between client and LS service.
    Parameters
    Hwnd     
    Handle of the application windows which will receive the notification messages.
    Hinst     
    Hinstance of the application window
    Type_com     
    Execution mode of the command:
    SUSPENSIVE_MODE = Synchronous mode
    NOT_SUSPENSIVE_MODE = Asynchronous mode
    Return Value
    LS100_OKAY if successful
    LS100_TRY_TO_RESET if the peripheral is in error state otherwise standard reply code.
    I have already the howto_ffi.html file and i have already did the following:
    - configuring the Webutil 1.0.5 (production release)
    - adding the library "LS100" to the Webutil.cfg
    - copy the library "LS100" and paste it into webutil\lib
    I also tried the following:
    I did omit the register/deregister_function, the code become as following and the same error occured after the 3rd add_parameter :
    declare
    ret_val      pls_integer;
    hwnd          number;     
    handle          number;     
    typ_com          varchar2(1):= 'S';
    len_typ          pls_integer := 1;
    f_handle      webutil_c_api.FunctionHandle;
    args          webutil_c_api.ParameterList;
    param1          webutil_c_api.ParameterHandle;
    param2          webutil_c_api.ParameterHandle;
    param3          webutil_c_api.ParameterHandle;
    xx number;
    yy number;
    begin
    -- f_handle := webutil_c_api.register_function('Ls100.dll','LS100_Open');
    args     := webutil_c_api.create_parameter_list;
    message('1');
    param1      := webutil_c_api.add_parameter(args,webutil_c_api.c_int,webutil_c_api.param_out,hwnd);
    message('2');
    param2      := webutil_c_api.add_parameter(args,webutil_c_api.c_int,webutil_c_api.param_out,handle);
    message('3');
    param3      := webutil_c_api.add_parameter(args,webutil_c_api.c_char,webutil_c_api.param_in,typ_com,len_typ);
    Now the same error appears in this stage:
    " WUL-910 Invoking the function failed: java.lang.IllegalArgumentException: unrecognized argument type "
    and the running continue
    message('before invoke_int');
    -- the "invoke_int" runs without any errors
    ret_val     := webutil_c_api.invoke_int('Ls100.dll','LS100_Open',args);
    xx := webutil_c_api.get_parameter_number(args,param1);
    yy := webutil_c_api.get_parameter_number(args,param2);
    message('hwnd ='||xx); -- => 0
    message('handle ='||yy); -- => 0
    message('ret_val ='||ret_val); -- => <nothing>
    WEBUTIL_C_API.Destroy_Parameter_List(args);
    --WEBUTIL_C_API.Deregister_Function(f_handle);                                        
    end;
    Thanks

  • Problem with ora_ffi

    Hi all
    I would know the current directory in my application with the employement of ora_ffi and I meet some problem like the return code not give the good result.
    I have whrite this code and I would know where is the error :
    PACKAGE BODY pkg_get_directory IS
              Libdirectory_lhandle Ora_Ffi.Libhandletype ;
    to_dir_fhandle Ora_Ffi.Funchandletype ;
    FUNCTION ff_to_dir(fhandle Ora_Ffi.Funchandletype,bufsz in number,lppath in out varchar2) RETURN NUMBER;
    PRAGMA interface(C, ff_to_dir, 11265);
    FUNCTION GetCurrentDirectory(bufsz in out number,lppath in out varchar2) RETURN NUMBER IS
    BEGIN
         RETURN(ff_to_dir(to_dir_fhandle,bufsz,lppath));
    END GetCurrentDirectory;
    BEGIN
         Libdirectory_lhandle := Ora_Ffi.Load_Library('C:\WINNT\SYSTEM32\','KERNEL32.dll');
         to_dir_fhandle := Ora_Ffi.Register_Function(Libdirectory_lhandle, 'GetCurrentDirectoryW', Ora_Ffi.C_Std);     
              Ora_Ffi.Register_Parameter(to_dir_fhandle, Ora_Ffi.C_DOUBLE_PTR);
              Ora_Ffi.Register_Parameter(to_dir_fhandle, Ora_Ffi.C_CHAR_PTR);
              Ora_Ffi.Register_Return(to_dir_fhandle, Ora_Ffi.C_DOUBLE);
    END;

    Noticed that I forgot to include the error. It comes from the "message" call I put in the exception block and reads:
    'Failure func_31_param: p31. Fatal Error: 304500: non-ORACLE exception'
    That 304500 isn't particularly informative. I've seen other posts of people getting this exception from ora_ffi.load_library

  • Doubt in ORA_FFI(Its urgent)

    Hi,
    I've created a test.dll which contains caps func as follows:
    int caps()
         int * ptr=0x417;
         if (*ptr==64)
              return 1;
    else
    return 0;
    Then I called this func through ORA_FFI package..
    DECLARE
    dll_handle ORA_FFI.LIBHANDLETYPE;
    winexec_handle ORA_FFI.FUNCHANDLETYPE;
    vn_ret PLS_INTEGER;
    FUNCTION Runp( handle IN ORA_FFI.FUNCHANDLETYPE)
    RETURN PLS_INTEGER;
    PRAGMA INTERFACE(C, Runp, 11265);
    BEGIN
    break;
    dll_handle := ORA_FFI.REGISTER_LIBRARY(NULL,'test.dll');
    winexec_handle := ORA_FFI.REGISTER_FUNCTION(dll_handle,'caps');
    ORA_FFI.REGISTER_RETURN(winexec_handle,ORA_FFI.C_INT);
    vn_ret := Runp(winexec_handle);
    IF vn_ret = 2 THEN
    MESSAGE('Cannot find file ' );
    END IF;
    EXCEPTION WHEN OTHERS THEN
    FOR i IN 1..Tool_Err.NErrors LOOP
    message(Tool_Err.Message);
    Tool_Err.Pop;
    END LOOP;
    END;
    When I debug this code,It gives error as caps func not found in test.dll.
    But the only func in test.dll is caps..
    I'm using forms 6i in client server mode.
    I created test.dll using Microsoft visual c++ by creating new win32 Dynamic link library.
    One more doubt:
    How can I find functions in a already compiled DLL?
    Pls reply me..Its urgent..
    Adios..
    Prashanth Deshmukh

    Hi,
    refer these ,u will get some help
    Standard Buttons:
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/webDynproABAP-ALVControllingStandard+Buttons&
    alv-pfstatus:
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_pfstatus.htm
    then how to capture that button click.
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_ucomm.htm
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rowsel.htm

  • Calling a dll from forms 6

    Hello,
    Sorry, I'm brazilian and my english isn't very good...
    I'm trying to call some functions from a dll invoked by a trigger on event WHEN-BUTTON-PRESSED. I make a package as this:
    ---- Package Spec ----
    PACKAGE anserlib IS
         function autoconnect(p_connport in number) return boolean;
    END;
    ---- Package Body ----
    PACKAGE BODY anserlib IS
         libhandle ora_ffi.libHandleType;
         autoconnect_fhandle ora_ffi.funchandletype;
         setprinton_fhandle ora_ffi.funchandletype;
         setprintoff_fhandle ora_ffi.funchandletype;
         res varchar2(200);
         commport number;
         function ff_autoconnect(fhandle ora_ffi.funchandletype, p_commport in number) return boolean;
         pragma interface(C, ff_autoconnect, 11265);
         function autoconnect(p_connport in number) return boolean is
         begin
              return(ff_autoconnect(autoconnect_fhandle,p_connport));
         end;
    begin
         libhandle := Ora_Ffi.Load_Library('C:\Juarez\Anser\','Anser712.dll');
         autoconnect_fhandle := ora_ffi.register_function(libhandle,'AutoConnect');
         ora_ffi.register_parameter(autoconnect_fhandle, ora_ffi.C_INT);
         ora_ffi.register_return(autoconnect_fhandle, ora_ffi.C_INT);
         setprinton_fhandle := ora_ffi.register_function(libhandle,'SetPrintOn');
         ora_ffi.register_return(setprinton_fhandle, ora_ffi.C_INT);
         setprintoff_fhandle := ora_ffi.register_function(libhandle,'SetPrintOff');
         ora_ffi.register_return(setprintoff_fhandle, ora_ffi.C_INT);
         ora_ffi.generate_foreign(libhandle, 'anser');
    exception
         when ora_ffi.ffi_error then
              --message(:bloco_teste.mensagem, acknowledge);
              message(tool_err.message, acknowledge);
    END;
    and the trigger is:
    declare
         v_res boolean;
         v_commport number;
    begin
         v_commport := 3;
         v_res := anserlib.autoconnect(v_commport);
    end;
    When I run the form and press button appears the message (it appears in portuguese to me, maybe the text is not the same in english, but i'll try to translate):
    FRM-40734: Internal Error: occours a PL/SQL error.
    Someone have an idea to help me...?
    Thanks vry much!!! :)

    In my opinion this error is something like 'General Protection Fault error' in Windows. I sow this error when my DLL worked with memory incorectly or called OCI functions which don't work under Forms Runtime.
    I think the problem might be caused by a mistake inside the DLL. The other problem may be that you use incorect calling conversion. For instance, the default calling conversion in Borland C Builder or Delphi is fastcall, not cdecl.
    p.s.
    1. Sorry for my English too :).
    2.
    ora_ffi.generate_foreign(libhandle, 'anser');I'm not sure what ora_ffi.generate_foreign does exactly, because I have never used it. As far as I know it isn't needed for this code. I'd recomend you to remove this line from your program.

  • Using ora_ffi to run window application

    Does anyone know how to use ora_ffi package to call a window
    application? ( I did not use host command because I wish to go
    back to the calling form. ) Thanks.
    null

    can write without a package too, in a trigger. This code is with error checking
    DECLARE
    dll_handle ORA_FFI.LIBHANDLETYPE;
    winexec_handle ORA_FFI.FUNCHANDLETYPE;
    vn_ret PLS_INTEGER;
    FUNCTION Runp( handle IN ORA_FFI.FUNCHANDLETYPE,
    cmd IN OUT VARCHAR2,
    disp_mode IN PLS_INTEGER)
    RETURN PLS_INTEGER;
    PRAGMA INTERFACE(C, Runp, 11265);
    BEGIN
    dll_handle := ORA_FFI.REGISTER_LIBRARY(NULL,'kernel32.dll');
    winexec_handle := ORA_FFI.REGISTER_FUNCTION(dll_handle,'WinExec');
    ORA_FFI.REGISTER_RETURN(winexec_handle,ORA_FFI.C_INT);
    ORA_FFI.REGISTER_PARAMETER(winexec_handle,ORA_FFI.C_CHAR_PTR);
    ORA_FFI.REGISTER_PARAMETER(winexec_handle,ORA_FFI.C_INT);
    vn_ret := Runp(winexec_handle,:control.path ,1);
    IF vn_ret = 2 THEN
    MESSAGE('Cannot find file ' &#0124; &#0124; :control.path);
    END IF;
    EXCEPTION WHEN OTHERS THEN
    FOR i IN 1..Tool_Err.NErrors LOOP
    message(Tool_Err.Message);
    Tool_Err.Pop;
    END LOOP;
    END;

  • Setting widows environment variable like "path "

    I want to set a new value for windows environment variable path. Is there any way to set change the varibale.

    You could also use ORA_FFI package to call Windows API function SetEnvironmentVariable. There is an example below.
    See also:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setenvironmentvariable.asp
    kernel_lhandle Ora_Ffi.Libhandletype;
    GetEnvironmentVariable_fhandle Ora_Ffi.Funchandletype;
    SetEnvironmentVariable_fhandle Ora_Ffi.Funchandletype;
    FUNCTION ff_GetEnvironmentVariable(
    fhandle Ora_Ffi.funchandletype,
    lpName varchar2,     -- address of environment variable name
    lpBuffer varchar2,     -- address of buffer for variable value
    nSize      pls_integer -- size of buffer, in characters
    ) RETURN pls_integer;
    PRAGMA interface( C, ff_GetEnvironmentVariable, 11265 );
    FUNCTION ff_SetEnvironmentVariable(
    fhandle Ora_Ffi.funchandletype,
    lpName varchar2,     -- address of environment variable name
    lpValue varchar2     -- address of variable value
    ) RETURN pls_integer;
    PRAGMA interface( C, ff_SetEnvironmentVariable, 11265 );
    function SetEnvironmentVariable(lpName varchar2, lpValue varchar2) return pls_integer IS
    BEGIN
    return ff_SetEnvironmentVariable( SetEnvironmentVariable_fhandle, lpName, lpValue );
    END;
    function GetEnvironmentVariable(
    lpName varchar2
    ) return varchar2 as
    lpBuffer char(2000);     -- address of buffer for variable value
    nSize      pls_integer; -- size of buffer, in characters
    res pls_integer;
    begin
    lpBuffer:='*';
    nSize:=2000-1;
    res:=ff_GetEnvironmentVariable(
    GetEnvironmentVariable_fhandle,
    lpName,
    lpBuffer,
    nSize );
    if res>0 then
    return substr( lpBuffer, 1, res );
    else
    return null;
    end if;
    end;
    -- Initialization
    /* Load the library */
    kernel_lhandle:=Ora_Ffi.Load_library
    ( '', 'kernel32.dll' );
    /* GetEnvironmentVariable */
    GetEnvironmentVariable_fhandle:=Ora_Ffi.Register_Function
    ( kernel_lhandle, 'GetEnvironmentVariableA', Ora_Ffi.C_Std );
    Ora_Ffi.Register_Parameter
    ( GetEnvironmentVariable_fhandle, Ora_Ffi.C_CHAR_PTR );
    Ora_Ffi.Register_Parameter
    ( GetEnvironmentVariable_fhandle, Ora_Ffi.C_CHAR_PTR );
    Ora_Ffi.Register_Parameter
    ( GetEnvironmentVariable_fhandle, Ora_Ffi.C_INT );
    Ora_Ffi.Register_Return
    ( GetEnvironmentVariable_fhandle, Ora_Ffi.C_INT );
    /* SetEnvironmentVariable */
    SetEnvironmentVariable_fhandle:=Ora_Ffi.Register_Function
    ( kernel_lhandle, 'SetEnvironmentVariableA', Ora_Ffi.C_Std );
    Ora_Ffi.Register_Parameter
    ( SetEnvironmentVariable_fhandle, Ora_Ffi.C_CHAR_PTR );
    Ora_Ffi.Register_Parameter
    ( SetEnvironmentVariable_fhandle, Ora_Ffi.C_CHAR_PTR );
    Ora_Ffi.Register_Return
    ( SetEnvironmentVariable_fhandle, Ora_Ffi.C_INT );
    To change the variable PATH you could use something like the following code:
    s:=dll_path||';'||WIN32.GetEnvironmentVariable( 'PATH' );
    res:=WIN32.SetEnvironmentVariable( 'PATH', s );

  • Creating an messagebox in forms with look and feel of Windows

    I wanted to create an message box in my form with look and feel of windows.For this i used the package ORA.FFI...but i am getting an error....and i am not bale to clear it...the code is as follows
    Package Specification: -
    PACKAGE messagebox IS
    /*Function message_box calls windows MessageBox function. */
    FUNCTION message_box(plptext IN VARCHAR2,plpcaption IN VARCHAR2)
    RETURN PLS_INTEGER;
    END;
    Package body : -
    PACKAGE BODY messagebox IS
    lh_window ORA_FFI.LIBHANDLETYPE;
    fh_mb ORA_FFI.FUNCHANDLETYPE;
    lh_forms ora_ffi.libHandleType;
    /* Function i_mbx acts as the interface to the Messagebox
    function in windows
    FUNCTION i_mbx(funchandle IN ORA_FFI.FUNCHANDLETYPE,
    plptext IN OUT VARCHAR2,
    plpcaption IN OUT VARCHAR2)
    RETURN PLS_INTEGER;
    PRAGMA interface(C,i_mbx,11265);
    FUNCTION message_box(plptext IN VARCHAR2,
    plpcaption IN VARCHAR2)
    RETURN PLS_INTEGER IS
    ltext VARCHAR2(500) := plptext;
    lcaption VARCHAR2(500) := plpcaption;
    BEGIN
    RETURN(i_mbx(fh_mb,ltext,lcaption));
    END;
    BEGIN
    lh_window := ORA_FFI.LOAD_LIBRARY('d:\','DclMsgBox.dll');
    fh_mb := ORA_FFI.REGISTER_FUNCTION(lh_window,'DclMsgBox',ORA_FFI.C_STD);
    ORA_FFI.REGISTER_RETURN(fh_mb,ORA_FFI.C_CHAR_PTR);
    ORA_FFI.REGISTER_RETURN(fh_mb,ORA_FFI.C_CHAR_PTR);
    --ORA_FFI.REGISTER_RETURN(fh_mb,ORA_FFI.C_INT);
    END;
    Now when i call this function in When-New-Form-Instance as
    declare
    p number;
    begin
    p:=messagebox.message_box('hello','test');
    end;
    I had created an dll for message box and placed the .dll and .lib files in the d:\ of my system.
    I get an error message when i run the app. The error is:
    The instruction at "0x005a3b24" referenced memory at "0x00000006".The memory could not be "read".
    Can anybody please tell me where have i gone wrong....

    Colin Martin wrote:
    I agree the leather look is horrible. It's just not a reflection of the cutting edge modern design we have all got to love over the years. If it has to be there at least give us a choice of looks.
    There is a word for this (not that one) - skeuomorph. Wikipedia defines this as 'a derivative object that retains ornamental design cues to a structure that was necessary in the original. Skeuomorphs may be deliberately employed to make the new look comfortably old and familiar'.
    Common examples are found in audio software with pictures of actual knobs that you turn, as here; and the leather-bound tear-off look of calendar and contacts on the iPad is the same principle: the intention is to make it familiar and friendly to people who might otherwise be frightened off by a modern look because they are not used to modern technology. The whole concept and look of the iOS operating system is being brought into use on Macs for the same reason, to encourage non-tech-savvy people not to be frightened of them.
    This is all very well in its way, but in these two particular cases the result is unfortunate, particularly for experienced users, and it really ought to be possible to choose between the looks (as you can with the Mail layouts), even if the skeuomorph is the default.

  • How to user 'wrap' to encapsulation my package?

    I can't find some document about how to use this command in
    linux,somebody help me??
    null

    ssr wrote:
    has any one come across this type of situation ?Yep. Been there and still are there. We have the same issue with our RuleGen product. It all boils down to that when IP protection has to be secured you must do it by legal rather than technological measures.
    now there is no code security , since the clients will unwrap the source and do modifications as they like and the software companies are in total loss
    There is one alternative: use PRAGMA INTERFACE(C, ...);
    Not a nice one, since it requires you to abandon PL/SQL and (re)write all code in a 3GL. But it's the one Oracle is using for their internal code.

  • FFI wrapping 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 */
    Forms 6i running on a XP Pro box pointing toward an 8i database.
    Running the code will kick me out with no error.
    Running in debug mode, I get a ORA-304500 error.
    Any ideas?
    Much thanks!

    1. You can use the D2KWUTIL library to get the computer name. There is
    the WIN_API_ENVIRONMENT.Get_Computer_Name function there.
    2. I believe the following code works too:
    ---- cut here ----
    PACKAGE BODY W IS
    kernel32_lhandle Ora_Ffi.Libhandletype;
    GetComputerName_fhandle Ora_Ffi.Funchandletype;
    FUNCTION ff_GetComputerName(
    fhandle Ora_Ffi.Funchandletype,
    lbBuffer varchar2,
    nSize pls_integer ) RETURN pls_integer;
    PRAGMA interface(C, ff_GetComputerName, 11265);
    FUNCTION GetComputerName RETURN varchar2 IS
    buf varchar2(1000);
    nSize pls_integer;
    ret pls_integer;
    BEGIN
    -- You have to initialize the buffer for a received information
    -- before you call the WinAPI function
    -- Allocates 1000 bytes for the buffer
    buf:=RPAD( '*', 1000, '*' );
    nSize:=length(buf)-1;
    ret:=ff_GetComputerName( GetComputerName_fhandle, buf, nSize );
    if ret=0 then
    -- If the function fails, the return value is zero.
    return NULL;
    end if;
    return substr( buf, 1, nSize );
    END;
    PROCEDURE Init IS
    BEGIN
    -- Load the library.
    kernel32_lhandle := Ora_Ffi.Load_Library( '', 'kernel32.dll' );     
    -- BOOL GetComputerName(
    -- LPTSTR lpBuffer, // address of name buffer
    -- LPDWORD nSize // address of size of name buffer
    GetComputerName_fhandle := Ora_Ffi.Register_Function(
    kernel32_lhandle,
    'GetComputerNameA',
    Ora_Ffi.C_Std );
    Ora_Ffi.Register_Parameter( GetComputerName_fhandle, Ora_Ffi.C_CHAR_PTR );
    Ora_Ffi.Register_Parameter( GetComputerName_fhandle, Ora_Ffi.C_INT_PTR );
    Ora_Ffi.Register_Return( GetComputerName_fhandle, Ora_Ffi.C_INT );
    END;
    BEGIN
    Init;
    END;
    ---- cut here ----

  • Pbm in Dll (pls Francois)

    Hi,
    I created a test.dll using Microsoft visual c++ by following steps.
    I opened a new project by
    New--Project--win32 dynamic link library
    I added a new src file test.c to project and edited it as:
    int caps()
    int *src=0x417;
    if (*src==64)
    return 1;
    else
    return 0;
    I added a header file test.h and added
    int caps()
    I compiled the test.c with no errors.Then I built test.dll by pressing make test.dll.
    Now If I view test.dll with a utility called DLLEXP(Utility to see func present in DLL),
    Caps is not appearing in it.Thats y forms is also giving an error like caps is not found in test.dll.
    I'm totally confused.
    What is wrong in my process?
    Pls its urgent...I've to use this dll in ORA_FFI package.
    Adios..

    Here is a Metalink sample
    The memory for the char pointer must be globally allocated using a GlobalAlloc
    (with the GMEM_FIXED flag) such that the memory is not resident on the stack.
    The problem with allocating memory on the stack for the pointer is that this
    memory block will be freed when the function exits and the returned pointer
    will become invalid.
    Here is a complete example showing a successful implementation of this
    functionality. Although the following code demonstrates a 16bit
    implementation, the same holds true for 32bit implementations.
    -- This calling trigger's code                                --
    declare
      -- Parameters
      parm1 VARCHAR2(128) := 'X';
      -- Return value
      rt VARCHAR2(512) := 'Hello Folks';
    begin
      rt := MyLib.MyFunc1( parm1 );
      Message(rt);
    end;
    -- This wrapper package's header                             --
    PACKAGE MyLib IS
      FUNCTION MyFunc1( parm1 IN OUT VARCHAR2 )
                        RETURN VARCHAR2;  
    END;
    -- This wrapper package's body                               --
    PACKAGE BODY MyLib IS
      lib_hndl  ora_ffi.libHandleType;  
      func_hndl ora_ffi.funcHandleType;  
      FUNCTION i_MyFunc1( func_hndl IN ora_ffi.funcHandleType,  
                          parm1 IN OUT VARCHAR2 )
                          RETURN VARCHAR2;  
      PRAGMA INTERFACE(C,i_MyFunc1,11265);  
      FUNCTION MyFunc1( parm1 IN OUT VARCHAR2 )
                          RETURN VARCHAR2 
      IS   
        parm1_l  VARCHAR2 := parm1;
        rc       VARCHAR2(512);
      BEGIN   
        rc  := i_MyFunc1(func_hndl, parm1_l);
        RETURN (rc);  
      END ;  
    BEGIN   
      lib_hndl := ora_ffi.load_library(NULL,'DLL16.DLL');  
      func_hndl :=
    ora_ffi.register_function(lib_hndl,'PASCAL_TEST',ora_ffi.PASCAL_STD);
      ora_ffi.register_parameter(func_hndl,ORA_FFI.C_CHAR_PTR);
      ora_ffi.register_return(func_hndl,ORA_FFI.C_CHAR_PTR);
    END;
    -- This DLL's DEF file                                       --
    LIBRARY      DLL16
    EXETYPE      WINDOWS
    CODE         PRELOAD MOVEABLE DISCARDABLE
    DATA         PRELOAD SINGLE
    HEAPSIZE     4096
    EXPORTS
                 WEP PRIVATE
                 Pascal_Test  @1
    -- This DLL's CPP file                                       --
    #include <windows.h>
    #include <string.h>
    int CALLBACK LibMain(HANDLE hInstance, WORD wDataSeg, WORD wHeapSize, LPSTR
    lpszCmdLine)
            if (wHeapSize > 0 )
                    UnlockData (0);  // Unlocks the library's data segment
            return 1;
    char* FAR PASCAL __export Pascal_Test (char* xyz)  
        HGLOBAL hgl;
        char FAR* abc;
        hgl = GlobalAlloc(GPTR, 256);
        abc = (char*)GlobalLock(hgl);
        strcpy(abc,"Hello World");
            GlobalUnlock(hgl);
            MessageBox(NULL,abc,"Pascal",MB_OK);
        return abc;
    }Hope this help
    Francois

  • Calling an EXE from Forms 4.5

    How do i call a windows Exe from forms. Whats the exact syntax to do that? Code sample would help.
    Thanks!

    Client/server mode calling an EXE from Forms 4.5
    The following is a Foreign Function Interface that I employed to launch an outside program in its own asynchronous window. It was a great alternative to the HOST command.
    The disadvantage to the HOST command was that the launched program would have to be closed before you could return to the form. With this method the the launched program
    could be minimized etc. and you could switch back and forth between forms and it.
    ===============================================================
    PACKAGE fp_winexec IS
    FUNCTION run(p_cmd IN OUT VARCHAR2)
    RETURN BOOLEAN;
    END;
    PACKAGE BODY fp_winexec IS
    dll_handle ORA_FFI.LIBHANDLETYPE;
    winexec_handle ORA_FFI.FUNCHANDLETYPE;
    FUNCTION RunICD(
    handle IN ORA_FFI.FUNCHANDLETYPE;
    cmd IN OUT VARCHAR2;
    disp_mode IN PLS_INTEGER)
    RETURN PLS_INTEGER;
    PRAGMA INTERFACE(C, RunICD, 11265);
    FUNCTION run(p_cmd IN OUT VARCHAR2)
    RETURN BOOLEAN IS
    v_tmp PLS_INTEGER;
    v_cmd VARCHAR2(2000) := p_cmd;
    v_retval BOOLEAN := TRUE;
    BEGIN
    v_tmp := RunICD(winexec_handle, v_cmd, 1);
    IF v_tmp = 2
    THEN
    MESSAGE('Cannot find '||v_cmd||' or one of its components);
    v_retval := FALSE;
    END IF;
    return(v_retval);
    END run;
    BEGIN
    dll_handle := ORA_FFI.REGISTER_LIBRARY
    (NULL, 'krn386.exe');
    winexec_handle := ORA_FFI.REGISTER_FUNCTION(dll_handle, 'WinExec', ORA_FFI.PASCAL_STD);
    ORA_FFI.REGISTER_RETURN(winexec_handle, ORA_FFI.C_INT);
    ORA_FFI.REGISTER_PARAMETER(winexec_handle, ORA_FFI.C_CHAR_PTR);
    ORA_FFI_REGISTER_PARAMETER(winexec_handle, ORA_FFI.C_INT);
    END;
    ====================================================================
    -- To call the program from forms
    DECLARE
    v_retval BOOLEAN;
    BEGIN
    v_retval := fp_winexec.run(:control_block.program_to_run);
    END;

Maybe you are looking for