Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IMetroMode::IsLauncherVia pInvoke在C#中可见吗?_C#_Windows 8_Pinvoke - Fatal编程技术网

IMetroMode::IsLauncherVia pInvoke在C#中可见吗?

IMetroMode::IsLauncherVia pInvoke在C#中可见吗?,c#,windows-8,pinvoke,C#,Windows 8,Pinvoke,在Windows 8的C#中,如何pInvoke IMetroMode::IsLauncherVisible方法 有关该方法的详细信息,请参见: 有两件事: 看起来像是IMetroModewas 在WinRT调用中不使用P/Invoke,而是应该在C项目中添加一个引用到C:\Program Files(x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral\中相应的WinMD文件中。这将提供具有自动完成功能的互操作服务,可以访问您

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

有关该方法的详细信息,请参见: 有两件事:

  • 看起来像是
    IMetroMode
    was
  • 在WinRT调用中不使用P/Invoke,而是应该在C项目中添加一个引用到
    C:\Program Files(x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral\
    中相应的WinMD文件中。这将提供具有自动完成功能的互操作服务,可以访问您需要的任何WinRT设施。你可以找到
  • 使用接口而不是

    以下是示例代码:

    /* 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接口定义:

    [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);
    }
    

    微软因“Metro”商标侵权而被起诉。所有内容都已重命名。
    IMetroMode
    /
    IAppVisibility
    不是WinRT的一部分;它们是标准的COM接口(由shell提供),恰好可以向基于WinRT的应用程序返回信息。1.只有从“开始”窗口启动应用程序时,才能正确检测桌面。2.如果你从桌面左上角点击同一个应用程序,代码会返回错误的答案。谢谢!请注意,这段代码也适用于我在Windows10中使用的基于WPF的应用程序。还有一个