By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,996 Members | 1,526 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,996 IT Pros & Developers. It's quick & easy.

SendInput() Always Returns "0"

P: n/a
Tim
Hello All,

I am writing a program that checks for the NumLock status and turns the NumLock on if it is off.
I'm not sure what I'm overlooking at this point, but the code will compile and run, but the SendInput call always returns "0".
Here is some of the code:

Beginning of Code...

[DllImport("user32.dll")]
static extern uint SendInput(uint nInputs, ref INPUT [] pInputs, int cbSize);

[StructLayout(LayoutKind.Explicit)]
public struct INPUT
{
[FieldOffset(0)] public int type;
[FieldOffset(4)] public KEYBDINPUT ki;
}
public struct KEYBDINPUT
{
public short wVk;
public short wScan;
public int dwFlags;
public int time;
public IntPtr dwExtraInfo;
}

....Code Deleted...

INPUT [] input = new INPUT [1];
input[0].ki.wVk = 0x90;
input[0].type = 0x01;
uint result;
result = SendInput(1, ref input, input.Length);

....End of Code

result will always equal "0". Does anyone know what would cause this, or even better, how to get this to work? I'm at a complete loss.

Thank you in advance for your help,
-Tim
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi
checkout the sample on this link

http://www.codeguru.com/vb/gen/vb_sy...cle.php/c4835/
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.