home *** CD-ROM | disk | FTP | other *** search
- REM TEACHING SCRIPT - FindWindow() API example [CorelSCRIPT 8]
- REM FindWindow.csc February 5, 1998
- REM ⌐ 1998 Corel Corporation. All rights reserved.
-
- REM **********************************************************************
- REM GENERAL INFORMATION
- REM This script demonstrates how to declare and call a function in a
- REM Dynamic Link Library (DLL).
- REM
- REM To use an API, you must know the API name, and how it is declared.
- REM You can find this information by using an API text viewer such as that
- REM provided with Visual Basic (Apilod32.exe)
- REM ***********************************************************************
-
- REM ***********************************************************************
- REM This example uses the function FindWindow() from the windows library:
- REM User32.dll. The FindWindow() function returns the handle of a window
- REM specified by lpClassName. If more than one window has the same
- REM "lpClassName", it returns the topmost window. If the specified
- REM application is not running, the function returns zero.
- REM ***********************************************************************
-
- ' Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- ' The above line shows the function as declared from the Visual Basic API text viewer.
- ' This declaration has to be modified slightly in order to work with Corel SCRIPT.
- ' The SCRIPT declaration places the 'ALIAS' at the end of the declaration.
-
- ' The second parameter 'lpWindowName' is declared as a LONG in SCRIPT. In order for
- ' the function to determine if the app is running (without having to specify an open file name),
- ' this parameter must be set to NULL. Since SCRIPT doesn't support NULL, this parameter is
- ' declared as a LONG, and is assigned the value zero.
-
- DECLARE FUNCTION FindWindow LIB "user32"(\\
- BYVAL lpClassName AS STRING, \\
- BYVAL lpWindowName AS LONG \\
- ) AS LONG ALIAS "FindWindowA"
-
- ' Call function to determine whether Ventura is running and display appropriate message
- IF FindWindow("Ventura 8.0", 0) = 0 THEN
- MESSAGE "Corel VENTURA 8 is not running"
- ELSE
- MESSAGE "Corel VENTURA 8 is running"
- ENDIF
-
-