共用方式為


interop::GetWindowIdFromWindow 函式 (microsoft.ui.interop.h)

如果 hwnd 自變數有效,則取得對應至指定之視窗句柄的 WindowId。如果 hwnd 自變數有效,則為 。

備註

microsoft.ui.interop.h 標頭相依於 microsoft.ui.h,它不會隨附於 Windows App SDK的一部分。 您可以在 Microsoft.UI.idl 上執行 MIDL 編譯程式 midl.exe,以產生 microsoft.ui.h。 或者,請改用 winrt/Microsoft.ui.interop.h 標頭中的函式。

C#。 對於 C# 傳統型應用程式開發人員,此標頭中的 Interop 函式會由 Microsoft.UI.Win32Interop 類別的方法包裝。

語法

HRESULT GetWindowIdFromWindow(
  HWND                           hwnd,
  ::ABI::Microsoft::UI::WindowId *windowId
) noexcept;

參數

hwnd

類型:HWND

要取得 WindowId之視窗的句柄。

windowId

類型:WindowId

如果 hwnd 有效,則對應至 hwnd的標識符。 否則,null

返回值

類型:HRESULT

如果函式成功,則傳回 S_OK。 否則,會傳回值,指出錯誤。

需求

要求 價值
最低支援的用戶端 Windows 10 版本 1809(含 Windows App SDK 1.0 或更新版本)
標題 microsoft.ui.interop.h

另請參閱

管理應用程式視窗