Share via


LockSetForegroundWindow 函式 (winuser.h)

前景進程可以呼叫 LockSetForegroundWindow 函式,以停用 對 SetForegroundWindow 函式的呼叫。

語法

BOOL LockSetForegroundWindow(
  [in] UINT uLockCode
);

參數

[in] uLockCode

類型: UINT

指定是否啟用或停用 對 SetForegroundWindow 的呼叫。 此參數可以是下列其中一個值。

意義
LSFW_LOCK
1
停用 對 SetForegroundWindow 的呼叫。
LSFW_UNLOCK
2
啟用 對 SetForegroundWindow 的呼叫。

傳回值

類型: BOOL

如果函式成功,則傳回非零的值。

如果此函式失敗,則傳回值為零。 若要取得擴充的錯誤資訊,請呼叫 GetLastError

備註

如果使用者按下 ALT 鍵或採取一些動作,讓系統自行變更前景視窗 (,例如按兩下背景視窗) ,系統會自動啟用 對 SetForegroundWindow 的呼叫。

提供此函式可讓應用程式防止其他應用程式進行前景變更,以中斷其與用戶的互動。

規格需求

需求
最低支援的用戶端 Windows 2000 專業版 [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 winuser.h (包括 Windows.h)
程式庫 User32.lib
Dll User32.dll
API 集合 ext-ms-win-ntuser-window-l1-1-3 (於 Windows 10 10.0.10240 版)

另請參閱

AllowSetForegroundWindow

概念

參考

SetForegroundWindow

Windows