有人可以找出为什么PKEY_EdgeGesture_DisableTouchWhenFullscreen
不再适用于Win 10周年更新以及如何解决问题?
目前我正在使用here中的Ron Schuler代码在我的应用中禁用边缘手势。
它在Win 10 RTM和Win 10 November Update(1151)中运行良好,但不再适用于Win 10周年更新。
并且不再有效,我的意思是没有错误或异常,只需调用该方法就不会禁用边缘手势。
不,重写Win 10 Kiosk模式的应用程序(例如,使其成为Metro或Universal App)不是解决方案!
由于我是c#开发人员而不是本地c ++开发者,我不知道如何解决这个问题...
我在c#中的代码:
internal static class EdgeGestureUtil
{
private static readonly short VT_BOOL = 11;
private static readonly Guid DISABLE_TOUCH_SCREEN = new Guid("32CE38B2-2C9A-41B1-9BC5-B3784394AA44");
private static Guid IID_PROPERTY_STORE = new Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99");
#region "Structures"
[StructLayout(LayoutKind.Sequential, Pack = 4)]
private struct PropertyKey
{
[MarshalAs(UnmanagedType.Struct)]
public Guid fmtid;
public uint pid;
public PropertyKey(Guid guid, UInt32 pid)
{
this.fmtid = guid;
this.pid = pid;
}
}
[StructLayout(LayoutKind.Explicit)]
private 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[this.blobVal.Length];
Marshal.Copy(this.blobVal.Data, result, 0, result.Length);
return result;
}
/// <summary>
/// Property value
/// </summary>
public object Value
{
get
{
VarEnum ve = (VarEnum)this.vt;
switch (ve)
{
case VarEnum.VT_I1:
return this.bVal;
case VarEnum.VT_I2:
return this.iVal;
case VarEnum.VT_I4:
return this.lVal;
case VarEnum.VT_I8:
return this.hVal;
case VarEnum.VT_INT:
return this.iVal;
case VarEnum.VT_UI4:
return this.ulVal;
case VarEnum.VT_LPWSTR:
return Marshal.PtrToStringUni(this.pwszVal);
case VarEnum.VT_BLOB:
return this.GetBlob();
default:
throw new NotImplementedException("PropVariant " + ve.ToString());
}
}
}
}
private 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()
{
this.Length = 0;
this.Data = IntPtr.Zero;
}
}
#endregion
#region "Interfaces"
[ComImport(), Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IPropertyStore
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void GetCount([In(), Out()] ref uint cProps);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void GetAt([In()] uint iProp, ref PropertyKey pkey);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void GetValue([In()] ref PropertyKey key, ref 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();
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void Release();
}
#endregion
#region "Methods"
[DllImport("shell32.dll", SetLastError = true)]
private static extern int SHGetPropertyStoreForWindow(IntPtr handle, ref Guid riid, ref IPropertyStore propertyStore);
internal static void DisableEdgeGestures(IntPtr hwnd, bool disable)
{
IPropertyStore pPropStore = null;
int hr = EdgeGestureUtil.SHGetPropertyStoreForWindow(hwnd, ref EdgeGestureUtil.IID_PROPERTY_STORE, ref pPropStore);
if (hr == 0)
{
PropertyKey propKey = new PropertyKey();
propKey.fmtid = EdgeGestureUtil.DISABLE_TOUCH_SCREEN;
propKey.pid = 2;
PropVariant var = new PropVariant();
var.vt = EdgeGestureUtil.VT_BOOL;
var.boolVal = disable;
pPropStore.SetValue(ref propKey, ref var);
Marshal.FinalReleaseComObject(pPropStore);
}
}
#endregion
}
答案 0 :(得分:-1)
我找到了一个解决方法:
如何在Windows 10中禁用触摸屏边缘滑动(仅限周年纪念版)
1)打开注册表编辑器 2)转到以下注册表项:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\EdgeUI
你可能没有这样的密钥,所以只需创建它。
3)创建一个名为AllowEdgeSwipe
的新32位DWORD值。将其值数据保留为0(零)以禁用边缘滑动
4)要应用更改,请重新启动Windows 10.
这当然会永久禁用边缘滑动。之前的PKEY_EdgeGesture_DisableTouchWhenFullscreen
方法仅允许在您的应用运行时禁用边缘滑动...