1. SearchProgramEnabled or notCode
Program fasttest; uses forms, windows, main in 'main \ main. pa' {frmmain}, welcome in 'main \ welcome. pa' {frmwelcome}, common in 'common \ common. pa', login 'login. pa' {frmlogin}; {$ R *. res} var found: hwnd; begin found: = findwindow (nil, pchar (Common. applicationtitle); // find the window if found <> 0 then begin // if found, activate the running program and end its own showwindow (found, sw_restore); exit; end; application. initialize; application. createform (tfrmlogin, frmlogin); application. run; end.
Ii. showwindow Function Description
[Dllimport ("user32.dll", entrypoint = "showwindow", charset = charset. Auto)]
Public static extern int showwindow (intptr hwnd, int ncmdshow );
Function: This function sets the display status of the specified window.
Parameters:
Hwnd: Window handle.
Ncmdshow: specifies how the window is displayed. If the program sending the application provides the startupinfo structure, this parameter is ignored when the application calls showwindow for the first time. Otherwise, when the showwindow function is called for the first time, the value should be the ncmdshow parameter in the winmain function. In subsequent calls, this parameter can be one of the following values:
Sw_forceminimize: minimizes the window in windownt5.0, even if the thread that owns the window is suspended. This parameter is used when windows are minimized from other threads.
Sw_mioe: Hide the window and activate other windows.
Sw_maximize: Maximize the specified window.
Sw_minimize: minimizes the specified window and activates the next top-level window in the Z sequence.
Sw_restore: activated and displayed in the window. If the window is minimized or maximized, the system restores the window to its original size and position. The flag should be specified by the application when the minimal window is restored.
Sw_show: the original size of the window is used to activate and display the window.
Sw_showdefault: The display status is set based on the sw_flag flag specified in the startupinfo structure. The startupinfo structure is passed to the CreateProcess function by the program that starts the application.
Sw_showmaximized: Activate the window and maximize it.
Sw_showminimized: activates the window and minimizes it.
Sw_showminnoactivate: the window is minimized, and the activation window remains active.
Sw_showna: display the window in the original status. The activation window remains active.
Sw_shownoactivate: displays the last window size and status. The activation window remains active.
Sw_shownomal: Activate and display a window. If the window is minimized or maximized, the system restores it to the original size and size. The application should specify this flag when displaying the window for the first time.
Return Value: if the window is visible before, the return value is non-zero. If the window is hidden before, the return value is zero.
Note: When the application calls showwindow for the first time, the ncmdshow parameter of the winmain function should be used as its ncmdshow parameter. When you call the showwindow function, you must use a given value in the list instead of the value specified by the ncmdshow parameter of the winmain function.
Public const sw_hide = 0
Public const sw_shownormal = 1
Public const sw_showminimized = 2
Public const sw_showmaximized = 3
Public const sw_maximize = 3
Public const sw_shownoactivate = 4
Public const sw_show = 5
Public const sw_minimize = 6
Public const sw_showminnoactive = 7
Public const sw_showna = 8
Public const sw_restore = 9