gpt4 book ai didi

c# - IMetroMode::IsLauncherVisible 在 C# 中通过 pInvoke?

转载 作者:行者123 更新时间:2023-12-02 05:33:38 29 4
gpt4 key购买 nike

在 Windows 8 的 C# 中,如何 pInvoke IMetroMode::IsLauncherVisible 方法?

该方法的详细信息可在此处找到: http://msdn.microsoft.com/en-us/library/windows/desktop/hh404166(v=vs.85).aspx

最佳答案

使用 IAppVisibility接口(interface)而不是 obsolete IMetroMode interface

示例代码如下:

/* From ShObjIdl.idl
// CLSID_AppVisibility
[ uuid(7E5FE3D9-985F-4908-91F9-EE19F9FD1514)] coclass AppVisibility { interface IAppVisibility; }
*/
Type tIAppVisibility = Type.GetTypeFromCLSID(new Guid("7E5FE3D9-985F-4908-91F9-EE19F9FD1514"));
IAppVisibility appVisibility = (IAppVisibility)Activator.CreateInstance(tIAppVisibility);
bool launcherVisible;
if(HRESULT.S_OK == appVisibility.IsLauncherVisible(out launcherVisible)) {
// Here you can use the launcherVisible flag
}

IAppVisibility 接口(interface)定义:

[ComImport, Guid("2246EA2D-CAEA-4444-A3C4-6DE827E44313"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAppVisibility {
HRESULT GetAppVisibilityOnMonitor([In] IntPtr hMonitor, [Out] out MONITOR_APP_VISIBILITY pMode);
HRESULT IsLauncherVisible([Out] out bool pfVisible);
HRESULT Advise([In] IAppVisibilityEvents pCallback, [Out] out int pdwCookie);
HRESULT Unadvise([In] int dwCookie);
}
//...
public enum HRESULT : long {
S_FALSE = 0x0001,
S_OK = 0x0000,
E_INVALIDARG = 0x80070057,
E_OUTOFMEMORY = 0x8007000E
}
public enum MONITOR_APP_VISIBILITY {
MAV_UNKNOWN = 0, // The mode for the monitor is unknown
MAV_NO_APP_VISIBLE = 1,
MAV_APP_VISIBLE = 2
}
[ComImport, Guid("6584CE6B-7D82-49C2-89C9-C6BC02BA8C38"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAppVisibilityEvents {
HRESULT AppVisibilityOnMonitorChanged(
[In] IntPtr hMonitor,
[In] MONITOR_APP_VISIBILITY previousMode,
[In] MONITOR_APP_VISIBILITY currentMode);

HRESULT LauncherVisibilityChange([In] bool currentVisibleState);
}

关于c# - IMetroMode::IsLauncherVisible 在 C# 中通过 pInvoke?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12009999/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com