## wb_get_instance

bool wb_get_instance (string caption [, bool bringtofront])

Detects a running instance of a WinBinder application.

# Detecting running instances

Each main window of all WinBinder applications stores a 32-bit identifier that is calculated according to the initial window caption and is unique to that caption. wb_get_instance() will try to find, among all current top-level windows, a WinBinder window that was created with the same caption. The function returns `TRUE` if it finds the existing window or `FALSE` if it is does not.

The function is effective even of the caption of the first instance of the application is changed at runtime because the 32-bit identifier does not change throughout the life of the application.

If bringtofront is set to TRUE, the function optionally restores the window (if minimized) and brings the corresponding window to the front of other windows.

# Example

`<? // This program creates a single-instance application include "../include/winbinder.php"; // Location of WinBinder library define("CAPTION", "Single instance test"); if(wb_get_instance(CAPTION, TRUE)) // Is there an existing instance? die; // Yes: bring it to the front and quit $mainwin = wb_create_window(NULL, // Create the main window AppWindow, CAPTION, 320, 140); wb_set_text($mainwin, "New caption"); // The window caption may change wb_main_loop(); ?>`

# See also

System functions