Marshal.PtrToStructure throwing System.ArgumentException error
问题 I'm attempting to get a KBDLLHOOKSTRUCT from a keyboard-hook's lParam. private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { KBDLLHOOKSTRUCT kbd = new KBDLLHOOKSTRUCT(); Marshal.PtrToStructure(lParam, kbd); // Throws System.ArguementException ... Unfortunately the PtrToStructure is throwing two A first chance exception of type 'System.ArgumentException' occurred in myprogram.exe errors every time a key is pressed. It also stops that method in its tracks. MSNDA says: