Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.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
C# 在WPF全屏应用程序中禁用Windows 8 CharmBar_C#_Wpf_Winapi_Charms Bar - Fatal编程技术网

C# 在WPF全屏应用程序中禁用Windows 8 CharmBar

C# 在WPF全屏应用程序中禁用Windows 8 CharmBar,c#,wpf,winapi,charms-bar,C#,Wpf,Winapi,Charms Bar,我想为Windows8创建一个新的全屏“kiosk”WPF应用程序。 它不是一个现代的UI应用程序 应用程序应自动启动,并且必须不可关闭。 一些事情已经实现了。 应用程序使用注册表值禁用硬件windows项,然后 从Windows开始 唯一不起作用的是禁用魅力栏。 我已经测试了很多东西,比如DisableCharmsHint注册表值。 但它不起作用。然后我在网上搜索,我看到了一个API调用,它应该禁用CharmsBar,但它不起作用。 我希望任何人都能帮忙 这是我的助手课。我使用主窗口句柄和fa

我想为Windows8创建一个新的全屏“kiosk”WPF应用程序。 它不是一个现代的UI应用程序

应用程序应自动启动,并且必须不可关闭。 一些事情已经实现了。 应用程序使用注册表值禁用硬件windows项,然后 从Windows开始

唯一不起作用的是禁用魅力栏。 我已经测试了很多东西,比如DisableCharmsHint注册表值。 但它不起作用。然后我在网上搜索,我看到了一个API调用,它应该禁用CharmsBar,但它不起作用。 我希望任何人都能帮忙

这是我的助手课。我使用主窗口句柄和false-disable调用enabledgegestures-Method

API调用SHGetPropertyStoreForWindow的结果始终为0

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

namespace Helpers {
    public class EdgeGestureUtil {
        #region Strukturen

        [StructLayout ( LayoutKind.Sequential, Pack = 4 )]
        public struct PropertyKey {
            public PropertyKey ( Guid guid, UInt32 pid ) {
                fmtid = guid;
                this.pid = pid;
            }

            [MarshalAs ( UnmanagedType.Struct )]
            public Guid fmtid;
            public uint pid;
        }

        [StructLayout ( LayoutKind.Explicit )]
        public struct PropVariant {
            [FieldOffset ( 0 )]
            public short vt;
            [FieldOffset ( 2 )]
            private short wReserved1;
            [FieldOffset ( 4 )]
            private short wReserved2;
            [FieldOffset ( 6 )]
            private short wReserved3;
            [FieldOffset ( 8 )]
            private sbyte cVal;
            [FieldOffset ( 8 )]
            private byte bVal;
            [FieldOffset ( 8 )]
            private short iVal;
            [FieldOffset ( 8 )]
            public ushort uiVal;
            [FieldOffset ( 8 )]
            private int lVal;
            [FieldOffset ( 8 )]
            private uint ulVal;
            [FieldOffset ( 8 )]
            private int intVal;
            [FieldOffset ( 8 )]
            private uint uintVal;
            [FieldOffset ( 8 )]
            private long hVal;
            [FieldOffset ( 8 )]
            private long uhVal;
            [FieldOffset ( 8 )]
            private float fltVal;
            [FieldOffset ( 8 )]
            private double dblVal;
            [FieldOffset ( 8 )]
            public bool boolVal;
            [FieldOffset ( 8 )]
            private int scode;
            //CY cyVal;
            [FieldOffset ( 8 )]
            private DateTime date;
            [FieldOffset ( 8 )]
            private System.Runtime.InteropServices.ComTypes.FILETIME filetime;
            //CLSID* puuid;
            //CLIPDATA* pclipdata;
            //BSTR bstrVal;
            //BSTRBLOB bstrblobVal;
            [FieldOffset ( 8 )]
            private Blob blobVal;
            //LPSTR pszVal;
            [FieldOffset ( 8 )]
            private IntPtr pwszVal;
            //LPWSTR 
            //IUnknown* punkVal;
            //IDispatch* pdispVal;
            //        IStream* pStream;
            //        IStorage* pStorage;
            //        LPVERSIONEDSTREAM pVersionedStream;
            //        LPSAFEARRAY parray;
            //        CAC cac;
            //        CAUB caub;
            //        CAI cai;
            //        CAUI caui;
            //        CAL cal;
            //        CAUL caul;
            //        CAH cah;
            //        CAUH cauh;
            //        CAFLT caflt;
            //        CADBL cadbl;
            //        CABOOL cabool;
            //        CASCODE cascode;
            //        CACY cacy;
            //        CADATE cadate;
            //        CAFILETIME cafiletime;
            //        CACLSID cauuid;
            //        CACLIPDATA caclipdata;
            //        CABSTR cabstr;
            //        CABSTRBLOB cabstrblob;
            //        CALPSTR calpstr;
            //        CALPWSTR calpwstr;
            //        CAPROPVARIANT capropvar;
            //        CHAR* pcVal;
            //        UCHAR* pbVal;
            //        SHORT* piVal;
            //        USHORT* puiVal;
            //        LONG* plVal;
            //        ULONG* pulVal;
            //        INT* pintVal;
            //        UINT* puintVal;
            //        FLOAT* pfltVal;
            //        DOUBLE* pdblVal;
            //        VARIANT_BOOL* pboolVal;
            //        DECIMAL* pdecVal;
            //        SCODE* pscode;
            //        CY* pcyVal;
            //        DATE* pdate;
            //        BSTR* pbstrVal;
            //        IUnknown** ppunkVal;
            //        IDispatch** ppdispVal;
            //        LPSAFEARRAY* pparray;
            //        PROPVARIANT* pvarVal;
            //        

            /// <summary>
            /// Helper method to gets blob data
            /// </summary>
            private byte[] GetBlob ( ) {
                byte[] Result = new byte[ blobVal.Length ];
                Marshal.Copy ( blobVal.Data, Result, 0, Result.Length );
                return Result;
            }

            /// <summary>
            /// Property value
            /// </summary>
            public object Value {
                get {
                    VarEnum ve = ( VarEnum ) vt;
                    switch ( ve ) {
                        case VarEnum.VT_I1:
                            return bVal;
                        case VarEnum.VT_I2:
                            return iVal;
                        case VarEnum.VT_I4:
                            return lVal;
                        case VarEnum.VT_I8:
                            return hVal;
                        case VarEnum.VT_INT:
                            return iVal;
                        case VarEnum.VT_UI4:
                            return ulVal;
                        case VarEnum.VT_LPWSTR:
                            return Marshal.PtrToStringUni ( pwszVal );
                        case VarEnum.VT_BLOB:
                            return GetBlob ( );
                    }
                    throw new NotImplementedException ( "PropVariant " + ve.ToString ( ) );
                }
            }
        }

        internal struct Blob {
            public int Length;

            public IntPtr Data;
            //Code Should Compile at warning level4 without any warnings, 
            //However this struct will give us Warning CS0649: Field [Fieldname] 
            //is never assigned to, and will always have its default value
            //You can disable CS0649 in the project options but that will disable
            //the warning for the whole project, it's a nice warning and we do want 
            //it in other places so we make a nice dummy function to keep the compiler
            //happy.
            private void FixCS0649 ( ) {
                Length = 0;
                Data = IntPtr.Zero;
            }
        }

        #endregion

        #region PropertyStore

        [ComImport, Guid ( "886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99" ), InterfaceType ( ComInterfaceType.InterfaceIsIUnknown )]
        interface IPropertyStore {
            [MethodImpl ( MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime )]
            void GetCount ( [Out] out uint cProps );

            [MethodImpl ( MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime )]
            void GetAt ( [In] uint iProp, out PropertyKey pkey );

            [MethodImpl ( MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime )]
            void GetValue ( [In] ref PropertyKey key, out PropVariant pv );

            [MethodImpl ( MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime )]
            void SetValue ( [In] ref PropertyKey key, [In] ref PropVariant pv );

            [MethodImpl ( MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime )]
            void Commit ( );
        }

        #endregion

        #region Methoden

        [DllImport ( "shell32.dll", SetLastError = true )]
        static extern int SHGetPropertyStoreForWindow ( 
            IntPtr handle, ref Guid riid, [Out, MarshalAs ( UnmanagedType.Interface )] out IPropertyStore propertyStore );

        public static void EnableEdgeGestures ( IntPtr hwnd, bool enable ) {



            IPropertyStore pPropStore = null;
            int hr = 0;
            hr = SHGetPropertyStoreForWindow (
                hwnd, ref IID_PROPERTY_STORE, out pPropStore );

            if ( hr == 0 ) {
                PropertyKey propKey = new PropertyKey ( );
                propKey.fmtid = DISABLE_TOUCH_SCREEN;
                propKey.pid = 2;
                PropVariant var = new PropVariant ( );
                var.vt = VT_BOOL;
                var.boolVal = enable;
                pPropStore.SetValue ( ref propKey, ref var );
                Marshal.FinalReleaseComObject ( pPropStore );
            }
        }

        #endregion

        static Guid DISABLE_TOUCH_SCREEN    = new Guid ( "32CE38B2-2C9A-41B1-9BC5-B3784394AA44" );
        static Guid IID_PROPERTY_STORE      = new Guid ( "886d8eeb-8cf2-4446-8d02-cdba1dbdcf99" );
        static short VT_BOOL                = 11;
    }
}
使用系统;
使用系统集合;
使用System.Collections.Generic;
使用系统数据;
使用系统诊断;
使用System.Runtime.InteropServices;
使用System.Runtime.CompilerServices;
命名空间帮助程序{
公共级EdgeGestureUtil{
#区域结构
[StructLayout(LayoutKind.Sequential,Pack=4)]
公共结构属性{
公共属性密钥(Guid,UInt32 pid){
fmtid=guid;
this.pid=pid;
}
[Marshallas(UnmanagedType.Struct)]
公共指南fmtid;
公共uint pid;
}
[StructLayout(LayoutKind.Explicit)]
公共结构专有变量{
[字段偏移量(0)]
公开短消息;
[现场偏移(2)]
私人短期服务1;
[现场偏移(4)]
私人短期服务2;
[现场偏移(6)]
私人短期服务3;
[现场偏移(8)]
私人sbyte cVal;
[现场偏移(8)]
私有字节bVal;
[现场偏移(8)]
私人短柄牙刷;
[现场偏移(8)]
公共卫生服务;
[现场偏移(8)]
私有内部lVal;
[现场偏移(8)]
尺骨私处;
[现场偏移(8)]
私人int intVal;
[现场偏移(8)]
私人单位;
[现场偏移(8)]
私人长hVal;
[现场偏移(8)]
私人长乌瓦;
[现场偏移(8)]
私人浮动外语教学;
[现场偏移(8)]
私人双dblVal;
[现场偏移(8)]
公共布尔布尔瓦尔;
[现场偏移(8)]
私家侦探;
//赛维;
[现场偏移(8)]
私人日期时间日期;
[现场偏移(8)]
private System.Runtime.InteropServices.ComTypes.FILETIME文件时间;
//CLSID*puuid;
//CLIPDATA*pclipdata;
//BSTR bstrVal;
//BSTRBLOB bstrblobVal;
[现场偏移(8)]
私人Blob blobVal;
//LPSTR-pszVal;
[现场偏移(8)]
私人IntPtr pwszVal;
//LPWSTR
//IUnknown*punkVal;
//IDispatch*pdispVal;
//IStream*pStream;
//史料*p存储;
//LPVERSIONEDSTREAM pVersionedStream;
//阵列阵列阵列阵列阵列;
//CAC-CAC;
//CAUB-CAUB;
//蔡才;
//尾尾;
//CAL-CAL;
//考尔考尔;
//卡卡;
//考考;
//CAFLT CAFLT;
//CADBL CADBL;
//卡布尔卡布尔;
//共源共栅;
//仙人掌;
//卡达特卡达特;
//咖啡时间咖啡时间;
//CACLSID-cauid;
//CACLIPDATA CACLIPDATA;
//CABSTR-CABSTR;
//CABSTRBLOB CABSTRBLOB;
//CALPSTR CALPSTR;
//CALPWSTR-CALPWSTR;
//CAPROPVARIANT capropvar;
//CHAR*pcVal;
//UCHAR*pbVal;
//短*皮瓦尔;
//乌肖特*普瓦尔;
//长*plVal;
//ULONG*pulVal;
//INT*pintVal;
//UINT*puintVal;
//浮动*pfltVal;
//双*pdblVal;
//变量布尔*pboolVal;
//十进制*pdecVal;
//SCODE*pscode;
//CY*pcyVal;
//日期*更新日期;
//BSTR*pbstrVal;
//i未知**p未知;
//IDispatch**ppdispVal;
//LPSAFEARRAY*pparray;
//前变异体*pvarVal;
//        
/// 
///获取blob数据的Helper方法
/// 
私有字节[]GetBlob(){
字节[]结果=新字节[blobVal.Length];
Marshal.Copy(blobVal.Data,Result,0,Result.Length);
返回结果;
}
/// 
///财产价值
/// 
公共对象价值{
得到{
VarEnum ve=(VarEnum)vt;
开关(ve){
案例VarEnum.VT_I1:
返回bVal;
案例VarEnum.VT_I2:
返回iVal;
案例VarEnum.VT_I4:
返回左心室;
案例VarEnum.VT_I8:
返回hVal;
case VarEnum.VT_