IMetroMode::IsLauncherVisible in C# via pInvoke?(IMetroMode::IsLauncherVisible 在 C# 中通过 pInvoke?)
问题描述
在 Windows 8 的 C# 中,如何 pInvoke IMetroMode::IsLauncherVisible 方法?
In C# in Windows 8, how can I pInvoke the IMetroMode::IsLauncherVisible method?
该方法的详细信息可在此处找到:http://msdn.microsoft.com/en-us/library/windows/desktop/hh404166(v=vs.85).aspx
Details for the method are found here: http://msdn.microsoft.com/en-us/library/windows/desktop/hh404166(v=vs.85).aspx
推荐答案
使用IAppVisibility 接口而不是 过时的 IMetroMode 接口
这里是示例代码:
/* 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 接口定义:
The IAppVisibility interface definition:
[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);
}
这篇关于IMetroMode::IsLauncherVisible 在 C# 中通过 pInvoke?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:IMetroMode::IsLauncherVisible 在 C# 中通过 pInvoke?
基础教程推荐
- 从 C# 控制相机设备 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 如果条件可以为空 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 将数据集转换为列表 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
