|
|
|
|
- Example: Calling a function of the Windows API with Callback
Example: Calling a function of the Windows API with Callback The following example is used to implement a trace file containing all the identifiers (handles) of the windows currently opened on the current computer. The StartATrace procedure opens the trace file and lists the windows via the ListWindows function of the User32 API. The EnumerateWindow procedure is called by the EnumWindows function of the User32 API whenever a window is found. This procedure is used to write the identifier of the window found into the trace file.
PROCEDURE StartATrace() // Open file nFile is int = fOpen("C:\WindowHandle.txt", foCreate) IF nFile = -1 THEN Error("Problem with the file") EndProgram() END // Start the enumeration CallDLL32("User32", "EnumWindows", &EnumerateWindow, nFile) // Close the file fClose(nFile)
PROCEDURE EnumerateWindow(nHwnd is int, nFile is int) // Write into the file fWriteLine(nFile, nHwnd) RETURN True
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|