Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.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# 如何在windows Xp中使用原始输入_C#_.net_Raw Input - Fatal编程技术网

C# 如何在windows Xp中使用原始输入

C# 如何在windows Xp中使用原始输入,c#,.net,raw-input,C#,.net,Raw Input,我已经尝试使用来自此的原始输入 我使用.NET4.0和Visual Studio 2010在Windows764位上开发 它在Windows7中工作得很好,但在我在WindowsXPServicePack3上测试程序后,它无法注册输入设备。这一步对于windowsxp可能会有一些错误,但在windows7中,它工作得很好 if(!Win32.RegisterRawInputDevices(rid, (uint)rid.Length, (uint)Marshal.SizeOf(rid[0]

我已经尝试使用来自此的原始输入

我使用
.NET4.0
Visual Studio 2010在Windows7
64位
上开发 它在Windows7中工作得很好,但在我在WindowsXPServicePack3上测试程序后,它无法注册输入设备。这一步对于windowsxp可能会有一些错误,但在windows7中,它工作得很好

    if(!Win32.RegisterRawInputDevices(rid, (uint)rid.Length, (uint)Marshal.SizeOf(rid[0])))
    {
        throw new ApplicationException("Failed to register raw input device(s).");
    }
Win32中导入User32.dll如下

[DllImport("User32.dll", SetLastError = true)]
internal static extern bool RegisterRawInputDevices(RawInputDevice[] pRawInputDevice, uint numberDevices, uint size);

如何使其在windows XP中工作。

对于初学者,您可以尝试读取返回的错误消息。我尝试过,但程序没有出错,只是在“Win32.RegisterRarWinputDevices(rid,(uint)rid.Length,(uint)Marshal.SizeOf(rid[0])”中始终返回false,我不确定imoort
User32.dll是否与Windows XP相同,请检查它返回的内容。我尝试按如下方式添加(!Win32.RegisterRarWinputDevices(rid,(uint)rid.Length,(uint)Marshal.SizeOf(rid[0]){string errorMessage=new Win32Exception(Marshal.GetLastWin32Error()).Message;System.Windows.Forms.MessageBox.Show(errorMessage);抛出新的ApplicationException(“未能注册原始输入设备”);}
但它只提醒“无效标志”。我想知道您是否找到了解决该问题的方法,我在Win XP上也面临同样的行为。Windows7和更高版本工作得很好。谢谢对于初学者,您可以尝试读取返回的错误消息。我尝试过,但程序没有错误,只是在“Win32.RegisterRarWinputDevices(rid,(uint)rid.Length,(uint)Marshal.SizeOf(rid[0])”中始终返回false,我不确定imoort
User32.dll是否与Windows XP相同,请检查它返回的内容。我尝试按如下方式添加(!Win32.RegisterRarWinputDevices(rid,(uint)rid.Length,(uint)Marshal.SizeOf(rid[0]){string errorMessage=new Win32Exception(Marshal.GetLastWin32Error()).Message;System.Windows.Forms.MessageBox.Show(errorMessage);抛出新的ApplicationException(“未能注册原始输入设备”);}
但它只提醒“无效标志”。我想知道您是否找到了解决该问题的方法,我在Win XP上也面临同样的行为。Windows7和更高版本工作得很好。谢谢