How do I turn off windows 8.1 gestures and setting charm bar on my touch Screen

前端 未结 3 1371
予麋鹿
予麋鹿 2021-01-16 09:27

I Have an Touch screen Dell and Windows 8.1 Single language installed, When I move my finger from Right edge towards the middle, Windows 8 will bring up setting charm bar OR

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-16 09:52

    Here is a way to do it via .NET interop instead of compiling a C++ native DLL:

    Imports System.Runtime.InteropServices
    Imports System.Runtime.CompilerServices
    
    Public Class EdgeGestureUtil
    
        Private Shared DISABLE_TOUCH_SCREEN As Guid = New Guid("32CE38B2-2C9A-41B1-9BC5-B3784394AA44")
        Private Shared IID_PROPERTY_STORE As Guid = New Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99")
        Private Shared VT_BOOL As Short = 11
    
    #Region "Structures"
    
         _
        Public Structure PropertyKey
            Public Sub New(guid As Guid, pid As UInt32)
                fmtid = guid
                Me.pid = pid
            End Sub
    
             _
            Public fmtid As Guid
            Public pid As UInteger
        End Structure
    
         _
        Public Structure PropVariant
             _
            Public vt As Short
             _
            Private wReserved1 As Short
             _
            Private wReserved2 As Short
             _
            Private wReserved3 As Short
             _
            Private cVal As SByte
             _
            Private bVal As Byte
             _
            Private iVal As Short
             _
            Public uiVal As UShort
             _
            Private lVal As Integer
             _
            Private ulVal As UInteger
             _
            Private intVal As Integer
             _
            Private uintVal As UInteger
             _
            Private hVal As Long
             _
            Private uhVal As Long
             _
            Private fltVal As Single
             _
            Private dblVal As Double
             _
            Public boolVal As Boolean
             _
            Private scode As Integer
            'CY cyVal;
             _
            Private [date] As DateTime
             _
            Private filetime As System.Runtime.InteropServices.ComTypes.FILETIME
            'CLSID* puuid;
            'CLIPDATA* pclipdata;
            'BSTR bstrVal;
            'BSTRBLOB bstrblobVal;
             _
            Private blobVal As Blob
            'LPSTR pszVal;
             _
            Private pwszVal As IntPtr
            '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;
            '        
    
            ''' 
            ''' Helper method to gets blob data
            ''' 
            Private Function GetBlob() As Byte()
                Dim Result As Byte() = New Byte(blobVal.Length - 1) {}
                Marshal.Copy(blobVal.Data, Result, 0, Result.Length)
                Return Result
            End Function
    
            ''' 
            ''' Property value
            ''' 
            Public ReadOnly Property Value() As Object
                Get
                    Dim ve As VarEnum = vt
                    Select Case 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()
                    End Select
                    Throw New NotImplementedException("PropVariant " + ve.ToString())
                End Get
            End Property
        End Structure
    
        Friend Structure Blob
            Public Length As Integer
            Public Data As IntPtr
    
            '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 Sub FixCS0649()
                Length = 0
                Data = IntPtr.Zero
            End Sub
        End Structure
    
    #End Region
    
    #Region "Interfaces"
    
         _
        Interface IPropertyStore
             _
            Sub GetCount( ByRef cProps As UInteger)
    
             _
            Sub GetAt(<[In]> iProp As UInteger, ByRef pkey As PropertyKey)
    
             _
            Sub GetValue(<[In]> ByRef key As PropertyKey, ByRef pv As PropVariant)
    
             _
            Sub SetValue(<[In]> ByRef key As PropertyKey, <[In]> ByRef pv As PropVariant)
    
             _
            Sub Commit()
    
             _
            Sub Release()
        End Interface
    
    #End Region
    
    #Region "Methods"
    
         _
        Private Shared Function SHGetPropertyStoreForWindow(handle As IntPtr, ByRef riid As Guid, ByRef propertyStore As IPropertyStore) As Integer
        End Function
    
        Public Shared Sub EnableEdgeGestures(ByVal hwnd As IntPtr, ByVal enable As Boolean)
            Dim pPropStore As IPropertyStore = Nothing
            Dim hr As Integer
            hr = SHGetPropertyStoreForWindow(hwnd, IID_PROPERTY_STORE, pPropStore)
            If hr = 0 Then
                Dim propKey As New PropertyKey
                propKey.fmtid = DISABLE_TOUCH_SCREEN
                propKey.pid = 2
                Dim var As New PropVariant
                var.vt = VT_BOOL
                var.boolVal = enable
                pPropStore.SetValue(propKey, var)
                Marshal.FinalReleaseComObject(pPropStore)
            End If
        End Sub
    
    #End Region
    
    End Class
    

提交回复
热议问题