c# Low Level Input Decode Message Params
I am making a low level keyboard hook that processes global key presses, forwarding this to the Raw Input API to check what keyboard device it came from.
I do this by using the SendMessage
function in my hook that can be received by the API.
My issue is that the API cannot read the buffer of the lParam, returning false
>> Error getting the rawinput buffer
How can I adapt the hook to allow that message's lParam to be successfully decoded by the API?
(I am using the Rawkeyboard struct and I feel like this may not be the correct one to use, I also tried using some others with no luck)
Hook
//^ DLL Imports, SetWindowsHookEx, etc^
public int HookProc(int Code, int wParam, ref CWPRETSTRUCT lParam) {
if (Code >= 0) {
// Block
Rawkeyboard lParamKeyboard = new Rawkeyboard();
int result = SendMessage(Handle, 0x00FF, wParam, ref lParamKeyboard ); // Send to API
if (result == 1) {
return 1;
}
}
// Allow
return CallNextHookEx(Handle, Code, wParam, ref lParam);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawkeyboard {
public ushort Makecode; // Scan code from the key depression
public ushort Flags; // One or more of RI_KEY_MAKE, RI_KEY_BREAK, RI_KEY_E0, RI_KEY_E1
private readonly ushort Reserved; // Always 0
public ushort VKey; // Virtual Key Code
public uint Message; // Corresponding Windows message for exmaple (WM_KEYDOWN, WM_SYASKEYDOWN etc)
public uint ExtraInformation; // The device-specific addition information for the event (seems to always be zero for keyboards)
public override string ToString() {
return string.Format("Rawkeyboardn Makecode: {0}n Makecode(hex) : {0:X}n Flags: {1}n Reserved: {2}n VKeyName: {3}n Message: {4}n ExtraInformation {5}n",
Makecode, Flags, Reserved, VKey, Message, ExtraInformation);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT {
IntPtr lResult;
IntPtr lParam;
IntPtr wParam;
uint message;
IntPtr hWnd;
}
API
protected override void WndProc(ref Message message){
switch (message.Msg){
// Message Received!
case 0x00FF:{
bool result = false;
hdevice = message.LParam;
if (_deviceList.Count == 0) return false;
var dwSize = 0;
Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(Rawinputheader)));
if (dwSize != Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof (Rawinputheader)))){
Debug.WriteLine("Error getting the rawinput buffer");
result = false;
}
else{
// Do checks here
result = true;
}
message.Result = (IntPtr)Convert.ToInt32(result);
}
break;
}
base.WndProc(ref message);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawinputheader
{
public uint dwType; // Type of raw input (RIM_TYPEHID 2, RIM_TYPEKEYBOARD 1, RIM_TYPEMOUSE 0)
public uint dwSize; // Size in bytes of the entire input packet of data. This includes RAWINPUT plus possible extra input reports in the RAWHID variable length array.
public IntPtr hDevice; // A handle to the device generating the raw input data.
public IntPtr wParam; // RIM_INPUT 0 if input occurred while application was in the foreground else RIM_INPUTSINK 1 if it was not.
public override string ToString()
{
return string.Format("RawInputHeadern dwType : {0}n dwSize : {1}n hDevice : {2}n wParam : {3}", dwType, dwSize, hDevice, wParam);
}
}
c# raw-input low-level
add a comment |
I am making a low level keyboard hook that processes global key presses, forwarding this to the Raw Input API to check what keyboard device it came from.
I do this by using the SendMessage
function in my hook that can be received by the API.
My issue is that the API cannot read the buffer of the lParam, returning false
>> Error getting the rawinput buffer
How can I adapt the hook to allow that message's lParam to be successfully decoded by the API?
(I am using the Rawkeyboard struct and I feel like this may not be the correct one to use, I also tried using some others with no luck)
Hook
//^ DLL Imports, SetWindowsHookEx, etc^
public int HookProc(int Code, int wParam, ref CWPRETSTRUCT lParam) {
if (Code >= 0) {
// Block
Rawkeyboard lParamKeyboard = new Rawkeyboard();
int result = SendMessage(Handle, 0x00FF, wParam, ref lParamKeyboard ); // Send to API
if (result == 1) {
return 1;
}
}
// Allow
return CallNextHookEx(Handle, Code, wParam, ref lParam);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawkeyboard {
public ushort Makecode; // Scan code from the key depression
public ushort Flags; // One or more of RI_KEY_MAKE, RI_KEY_BREAK, RI_KEY_E0, RI_KEY_E1
private readonly ushort Reserved; // Always 0
public ushort VKey; // Virtual Key Code
public uint Message; // Corresponding Windows message for exmaple (WM_KEYDOWN, WM_SYASKEYDOWN etc)
public uint ExtraInformation; // The device-specific addition information for the event (seems to always be zero for keyboards)
public override string ToString() {
return string.Format("Rawkeyboardn Makecode: {0}n Makecode(hex) : {0:X}n Flags: {1}n Reserved: {2}n VKeyName: {3}n Message: {4}n ExtraInformation {5}n",
Makecode, Flags, Reserved, VKey, Message, ExtraInformation);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT {
IntPtr lResult;
IntPtr lParam;
IntPtr wParam;
uint message;
IntPtr hWnd;
}
API
protected override void WndProc(ref Message message){
switch (message.Msg){
// Message Received!
case 0x00FF:{
bool result = false;
hdevice = message.LParam;
if (_deviceList.Count == 0) return false;
var dwSize = 0;
Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(Rawinputheader)));
if (dwSize != Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof (Rawinputheader)))){
Debug.WriteLine("Error getting the rawinput buffer");
result = false;
}
else{
// Do checks here
result = true;
}
message.Result = (IntPtr)Convert.ToInt32(result);
}
break;
}
base.WndProc(ref message);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawinputheader
{
public uint dwType; // Type of raw input (RIM_TYPEHID 2, RIM_TYPEKEYBOARD 1, RIM_TYPEMOUSE 0)
public uint dwSize; // Size in bytes of the entire input packet of data. This includes RAWINPUT plus possible extra input reports in the RAWHID variable length array.
public IntPtr hDevice; // A handle to the device generating the raw input data.
public IntPtr wParam; // RIM_INPUT 0 if input occurred while application was in the foreground else RIM_INPUTSINK 1 if it was not.
public override string ToString()
{
return string.Format("RawInputHeadern dwType : {0}n dwSize : {1}n hDevice : {2}n wParam : {3}", dwType, dwSize, hDevice, wParam);
}
}
c# raw-input low-level
Can you try withif (Win32.GetRawInputData(...) != dwSize
and confirm if you still get the error?
– Xiaoy312
Nov 21 at 3:54
@Xiaoy312 yes, still the same error, switching the operator behind has no effect, thanks though! :)
– SillySam
Nov 21 at 3:58
Capture the result of first api and check last error?var result = Win32.GetRaw...(); if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Check if this gives you anything.
– Xiaoy312
Nov 21 at 4:04
Wow, thanks! I got aSystem.ComponentModel.Win32Exception (0x80004005): The handle is invalid
error, this must relate to @shingo 's responce
– SillySam
Nov 21 at 4:20
add a comment |
I am making a low level keyboard hook that processes global key presses, forwarding this to the Raw Input API to check what keyboard device it came from.
I do this by using the SendMessage
function in my hook that can be received by the API.
My issue is that the API cannot read the buffer of the lParam, returning false
>> Error getting the rawinput buffer
How can I adapt the hook to allow that message's lParam to be successfully decoded by the API?
(I am using the Rawkeyboard struct and I feel like this may not be the correct one to use, I also tried using some others with no luck)
Hook
//^ DLL Imports, SetWindowsHookEx, etc^
public int HookProc(int Code, int wParam, ref CWPRETSTRUCT lParam) {
if (Code >= 0) {
// Block
Rawkeyboard lParamKeyboard = new Rawkeyboard();
int result = SendMessage(Handle, 0x00FF, wParam, ref lParamKeyboard ); // Send to API
if (result == 1) {
return 1;
}
}
// Allow
return CallNextHookEx(Handle, Code, wParam, ref lParam);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawkeyboard {
public ushort Makecode; // Scan code from the key depression
public ushort Flags; // One or more of RI_KEY_MAKE, RI_KEY_BREAK, RI_KEY_E0, RI_KEY_E1
private readonly ushort Reserved; // Always 0
public ushort VKey; // Virtual Key Code
public uint Message; // Corresponding Windows message for exmaple (WM_KEYDOWN, WM_SYASKEYDOWN etc)
public uint ExtraInformation; // The device-specific addition information for the event (seems to always be zero for keyboards)
public override string ToString() {
return string.Format("Rawkeyboardn Makecode: {0}n Makecode(hex) : {0:X}n Flags: {1}n Reserved: {2}n VKeyName: {3}n Message: {4}n ExtraInformation {5}n",
Makecode, Flags, Reserved, VKey, Message, ExtraInformation);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT {
IntPtr lResult;
IntPtr lParam;
IntPtr wParam;
uint message;
IntPtr hWnd;
}
API
protected override void WndProc(ref Message message){
switch (message.Msg){
// Message Received!
case 0x00FF:{
bool result = false;
hdevice = message.LParam;
if (_deviceList.Count == 0) return false;
var dwSize = 0;
Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(Rawinputheader)));
if (dwSize != Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof (Rawinputheader)))){
Debug.WriteLine("Error getting the rawinput buffer");
result = false;
}
else{
// Do checks here
result = true;
}
message.Result = (IntPtr)Convert.ToInt32(result);
}
break;
}
base.WndProc(ref message);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawinputheader
{
public uint dwType; // Type of raw input (RIM_TYPEHID 2, RIM_TYPEKEYBOARD 1, RIM_TYPEMOUSE 0)
public uint dwSize; // Size in bytes of the entire input packet of data. This includes RAWINPUT plus possible extra input reports in the RAWHID variable length array.
public IntPtr hDevice; // A handle to the device generating the raw input data.
public IntPtr wParam; // RIM_INPUT 0 if input occurred while application was in the foreground else RIM_INPUTSINK 1 if it was not.
public override string ToString()
{
return string.Format("RawInputHeadern dwType : {0}n dwSize : {1}n hDevice : {2}n wParam : {3}", dwType, dwSize, hDevice, wParam);
}
}
c# raw-input low-level
I am making a low level keyboard hook that processes global key presses, forwarding this to the Raw Input API to check what keyboard device it came from.
I do this by using the SendMessage
function in my hook that can be received by the API.
My issue is that the API cannot read the buffer of the lParam, returning false
>> Error getting the rawinput buffer
How can I adapt the hook to allow that message's lParam to be successfully decoded by the API?
(I am using the Rawkeyboard struct and I feel like this may not be the correct one to use, I also tried using some others with no luck)
Hook
//^ DLL Imports, SetWindowsHookEx, etc^
public int HookProc(int Code, int wParam, ref CWPRETSTRUCT lParam) {
if (Code >= 0) {
// Block
Rawkeyboard lParamKeyboard = new Rawkeyboard();
int result = SendMessage(Handle, 0x00FF, wParam, ref lParamKeyboard ); // Send to API
if (result == 1) {
return 1;
}
}
// Allow
return CallNextHookEx(Handle, Code, wParam, ref lParam);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawkeyboard {
public ushort Makecode; // Scan code from the key depression
public ushort Flags; // One or more of RI_KEY_MAKE, RI_KEY_BREAK, RI_KEY_E0, RI_KEY_E1
private readonly ushort Reserved; // Always 0
public ushort VKey; // Virtual Key Code
public uint Message; // Corresponding Windows message for exmaple (WM_KEYDOWN, WM_SYASKEYDOWN etc)
public uint ExtraInformation; // The device-specific addition information for the event (seems to always be zero for keyboards)
public override string ToString() {
return string.Format("Rawkeyboardn Makecode: {0}n Makecode(hex) : {0:X}n Flags: {1}n Reserved: {2}n VKeyName: {3}n Message: {4}n ExtraInformation {5}n",
Makecode, Flags, Reserved, VKey, Message, ExtraInformation);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT {
IntPtr lResult;
IntPtr lParam;
IntPtr wParam;
uint message;
IntPtr hWnd;
}
API
protected override void WndProc(ref Message message){
switch (message.Msg){
// Message Received!
case 0x00FF:{
bool result = false;
hdevice = message.LParam;
if (_deviceList.Count == 0) return false;
var dwSize = 0;
Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(Rawinputheader)));
if (dwSize != Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof (Rawinputheader)))){
Debug.WriteLine("Error getting the rawinput buffer");
result = false;
}
else{
// Do checks here
result = true;
}
message.Result = (IntPtr)Convert.ToInt32(result);
}
break;
}
base.WndProc(ref message);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawinputheader
{
public uint dwType; // Type of raw input (RIM_TYPEHID 2, RIM_TYPEKEYBOARD 1, RIM_TYPEMOUSE 0)
public uint dwSize; // Size in bytes of the entire input packet of data. This includes RAWINPUT plus possible extra input reports in the RAWHID variable length array.
public IntPtr hDevice; // A handle to the device generating the raw input data.
public IntPtr wParam; // RIM_INPUT 0 if input occurred while application was in the foreground else RIM_INPUTSINK 1 if it was not.
public override string ToString()
{
return string.Format("RawInputHeadern dwType : {0}n dwSize : {1}n hDevice : {2}n wParam : {3}", dwType, dwSize, hDevice, wParam);
}
}
c# raw-input low-level
c# raw-input low-level
edited Nov 22 at 5:09
asked Nov 21 at 3:32
SillySam
526
526
Can you try withif (Win32.GetRawInputData(...) != dwSize
and confirm if you still get the error?
– Xiaoy312
Nov 21 at 3:54
@Xiaoy312 yes, still the same error, switching the operator behind has no effect, thanks though! :)
– SillySam
Nov 21 at 3:58
Capture the result of first api and check last error?var result = Win32.GetRaw...(); if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Check if this gives you anything.
– Xiaoy312
Nov 21 at 4:04
Wow, thanks! I got aSystem.ComponentModel.Win32Exception (0x80004005): The handle is invalid
error, this must relate to @shingo 's responce
– SillySam
Nov 21 at 4:20
add a comment |
Can you try withif (Win32.GetRawInputData(...) != dwSize
and confirm if you still get the error?
– Xiaoy312
Nov 21 at 3:54
@Xiaoy312 yes, still the same error, switching the operator behind has no effect, thanks though! :)
– SillySam
Nov 21 at 3:58
Capture the result of first api and check last error?var result = Win32.GetRaw...(); if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Check if this gives you anything.
– Xiaoy312
Nov 21 at 4:04
Wow, thanks! I got aSystem.ComponentModel.Win32Exception (0x80004005): The handle is invalid
error, this must relate to @shingo 's responce
– SillySam
Nov 21 at 4:20
Can you try with
if (Win32.GetRawInputData(...) != dwSize
and confirm if you still get the error?– Xiaoy312
Nov 21 at 3:54
Can you try with
if (Win32.GetRawInputData(...) != dwSize
and confirm if you still get the error?– Xiaoy312
Nov 21 at 3:54
@Xiaoy312 yes, still the same error, switching the operator behind has no effect, thanks though! :)
– SillySam
Nov 21 at 3:58
@Xiaoy312 yes, still the same error, switching the operator behind has no effect, thanks though! :)
– SillySam
Nov 21 at 3:58
Capture the result of first api and check last error?
var result = Win32.GetRaw...(); if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Check if this gives you anything.– Xiaoy312
Nov 21 at 4:04
Capture the result of first api and check last error?
var result = Win32.GetRaw...(); if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Check if this gives you anything.– Xiaoy312
Nov 21 at 4:04
Wow, thanks! I got a
System.ComponentModel.Win32Exception (0x80004005): The handle is invalid
error, this must relate to @shingo 's responce– SillySam
Nov 21 at 4:20
Wow, thanks! I got a
System.ComponentModel.Win32Exception (0x80004005): The handle is invalid
error, this must relate to @shingo 's responce– SillySam
Nov 21 at 4:20
add a comment |
1 Answer
1
active
oldest
votes
The type of lParam
for HookProc
and SendMessage(WM_INPUT)
are different.
For HookProc
, it's CWPRETSTRUCT structure.
For SendMessage(WM_INPUT)
, it's RAWINPUT structure.
So you need to create a new RAWINPUT
object then pass to the SendMessage
method.
Hey, can you look at my edits to see if they are what you suggested, still getting the same error ;(
– SillySam
Nov 22 at 5:10
I'm wrong, send WM_INPUT message need RAWINPUT structure, it contains RAWKEYBOARD structure.
– shingo
Nov 22 at 5:55
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404879%2fc-sharp-low-level-input-decode-message-params%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The type of lParam
for HookProc
and SendMessage(WM_INPUT)
are different.
For HookProc
, it's CWPRETSTRUCT structure.
For SendMessage(WM_INPUT)
, it's RAWINPUT structure.
So you need to create a new RAWINPUT
object then pass to the SendMessage
method.
Hey, can you look at my edits to see if they are what you suggested, still getting the same error ;(
– SillySam
Nov 22 at 5:10
I'm wrong, send WM_INPUT message need RAWINPUT structure, it contains RAWKEYBOARD structure.
– shingo
Nov 22 at 5:55
add a comment |
The type of lParam
for HookProc
and SendMessage(WM_INPUT)
are different.
For HookProc
, it's CWPRETSTRUCT structure.
For SendMessage(WM_INPUT)
, it's RAWINPUT structure.
So you need to create a new RAWINPUT
object then pass to the SendMessage
method.
Hey, can you look at my edits to see if they are what you suggested, still getting the same error ;(
– SillySam
Nov 22 at 5:10
I'm wrong, send WM_INPUT message need RAWINPUT structure, it contains RAWKEYBOARD structure.
– shingo
Nov 22 at 5:55
add a comment |
The type of lParam
for HookProc
and SendMessage(WM_INPUT)
are different.
For HookProc
, it's CWPRETSTRUCT structure.
For SendMessage(WM_INPUT)
, it's RAWINPUT structure.
So you need to create a new RAWINPUT
object then pass to the SendMessage
method.
The type of lParam
for HookProc
and SendMessage(WM_INPUT)
are different.
For HookProc
, it's CWPRETSTRUCT structure.
For SendMessage(WM_INPUT)
, it's RAWINPUT structure.
So you need to create a new RAWINPUT
object then pass to the SendMessage
method.
edited Nov 22 at 5:54
answered Nov 21 at 4:04
shingo
1,1111414
1,1111414
Hey, can you look at my edits to see if they are what you suggested, still getting the same error ;(
– SillySam
Nov 22 at 5:10
I'm wrong, send WM_INPUT message need RAWINPUT structure, it contains RAWKEYBOARD structure.
– shingo
Nov 22 at 5:55
add a comment |
Hey, can you look at my edits to see if they are what you suggested, still getting the same error ;(
– SillySam
Nov 22 at 5:10
I'm wrong, send WM_INPUT message need RAWINPUT structure, it contains RAWKEYBOARD structure.
– shingo
Nov 22 at 5:55
Hey, can you look at my edits to see if they are what you suggested, still getting the same error ;(
– SillySam
Nov 22 at 5:10
Hey, can you look at my edits to see if they are what you suggested, still getting the same error ;(
– SillySam
Nov 22 at 5:10
I'm wrong, send WM_INPUT message need RAWINPUT structure, it contains RAWKEYBOARD structure.
– shingo
Nov 22 at 5:55
I'm wrong, send WM_INPUT message need RAWINPUT structure, it contains RAWKEYBOARD structure.
– shingo
Nov 22 at 5:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404879%2fc-sharp-low-level-input-decode-message-params%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you try with
if (Win32.GetRawInputData(...) != dwSize
and confirm if you still get the error?– Xiaoy312
Nov 21 at 3:54
@Xiaoy312 yes, still the same error, switching the operator behind has no effect, thanks though! :)
– SillySam
Nov 21 at 3:58
Capture the result of first api and check last error?
var result = Win32.GetRaw...(); if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Check if this gives you anything.– Xiaoy312
Nov 21 at 4:04
Wow, thanks! I got a
System.ComponentModel.Win32Exception (0x80004005): The handle is invalid
error, this must relate to @shingo 's responce– SillySam
Nov 21 at 4:20