Re: ORA_FFI: FindWindowA
Date: Mon, 20 Jul 1998 04:50:11 GMT
Message-ID: <6ouia3$6hm$1_at_nnrp1.dejanews.com>
Hi Miodrag,
Try the following:
o Create a Package Spec called something like FFI_USER32. It should look like:
PACKAGE FFI_USER32 IS
FUNCTION FindWindowA (lpszClassName IN OUT VARCHAR2,
lpszWindowName IN OUT VARCHAR2)
RETURN PLS_INTEGER;
END;
o Then create a Package Body called FFI_USER32 to look like this:
PACKAGE BODY FFI_USER32 IS
lh_User32 ORA_FFI.LIBHANDLETYPE; fh_FindWindowA ORA_FFI.FUNCHANDLETYPE; FUNCTION icd_FindWindowA (funcHandle IN ORA_FFI.FUNCHANDLETYPE, lpszClassName IN OUT VARCHAR2, lpszWindowName IN OUT VARCHAR2)
RETURN PLS_INTEGER;
PRAGMA INTERFACE(C,icd_FindWindowA,11265);
FUNCTION FindWindowA (lpszClassName IN OUT VARCHAR2,
lpszWindowName IN OUT VARCHAR2)
RETURN PLS_INTEGER IS
rc PLS_INTEGER;
BEGIN
rc := icd_FindWindowA(fh_FindWindowA, lpszClassName, lpszWindowName);
RETURN(rc);
END;
BEGIN
BEGIN
lh_User32 := ORA_FFI.FIND_LIBRARY('USER32.DLL'); EXCEPTION WHEN ORA_FFI.FFI_ERROR THEN lh_User32 := ORA_FFI.LOAD_LIBRARY(Null,'USER32.DLL');END; fh_FindWindowA :=
ORA_FFI.REGISTER_FUNCTION(lh_User32, 'FindWindowA', ORA_FFI.PASCAL_STD); ORA_FFI.REGISTER_PARAMETER(fh_FindWindowA, ORA_FFI.C_CHAR_PTR); ORA_FFI.REGISTER_PARAMETER(fh_FindWindowA, ORA_FFI.C_CHAR_PTR); ORA_FFI.REGISTER_RETURN(fh_FindWindowA, ORA_FFI.C_INT);END; o Place a button on your form and attach the following code as the WHEN-BUTTON- PRESSED trigger:
DECLARE
FindWindowARetVal PLS_INTEGER;
AppClassName VARCHAR2(7) := 'XLMAIN'; --Want to see if Excel is running.
AppWindowName VARCHAR2(1) := NULL;
BEGIN
FindWindowARetVal := FFI_USER32.FindWindowA(AppClassName, AppWindowName);
IF FindWindowARetVal = 0 THEN
Message('Excel is not running.');
ELSE
Message('Excel is running. Handle value = '||TO_CHAR(FindWindowARetVal));
END IF;
END;
This will tell you if Excel is running. If you want to detect another
application you'll need to know that application's Class Name (e.g., Word95's
class name is 'OpusApp', for some reason).
Hope this helps!
Neil W. Garside
Brisbane, Australia.
In article <35A3B157.90103B48_at_oma.org>,
Miodrag Stojanovic <miodrag_stojanovic_at_oma.org> wrote:
> Did anyone tried (and succeeded) to create PL/SQL function based on
> FindWindowA foreign function from user32.dll?
>
> API function is
>
> HWND FindWindowA(
> LPCTSTR lpClassName, // pointer to class name
> LPCTSTR lpWindowName // pointer to window name
> );
>
> I created PL/SQL function, but when I run, function always returns 0 as
> result. Maybe, I am not passing good parameters?
>
> Help. Thanks.
> Miodrag Stojanovic
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Mon Jul 20 1998 - 06:50:11 CEST