Click here to Skip to main content
15,911,789 members
Home / Discussions / C#
   

C#

 
Questionfocus on a treeview node Pin
Krazy Programmer9-Mar-08 20:51
Krazy Programmer9-Mar-08 20:51 
GeneralRe: focus on a treeview node Pin
C1AllenS9-Mar-08 21:04
C1AllenS9-Mar-08 21:04 
GeneralRe: focus on a treeview node Pin
Krazy Programmer9-Mar-08 22:43
Krazy Programmer9-Mar-08 22:43 
GeneralExport CR xi to PDF Pin
fakeer4uever9-Mar-08 20:34
fakeer4uever9-Mar-08 20:34 
GeneralRe: Export CR xi to PDF Pin
Christian Graus9-Mar-08 20:40
protectorChristian Graus9-Mar-08 20:40 
GeneralRe: Export CR xi to PDF Pin
Vikram A Punathambekar9-Mar-08 21:50
Vikram A Punathambekar9-Mar-08 21:50 
GeneralRe: Export CR xi to PDF Pin
Christian Graus9-Mar-08 23:32
protectorChristian Graus9-Mar-08 23:32 
QuestionSetWindowsHookEx (keylogger app) - Memory Access Violation Pin
amirreza_nl9-Mar-08 19:19
amirreza_nl9-Mar-08 19:19 
Hi,
I wrote a piece of code to monitor keyword activities (just for fun and testing this api func) I want to know what is wrong? sometime I get this error:
{"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}

Stack trace:
" at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run()\r\n at hook.Program.Main() in C:\\Documents and Settings\\Nazila\\My Documents\\Visual Studio 2005\\Projects\\hook\\hook\\Program.cs:line 19"

my code is :

public class KeyPosition<br />
{<br />
     static public Int16  WM_KEYDOWN = 0x0100;<br />
     static public Int16 WM_KEYUP = 0x0101;<br />
     static public Int16 WM_SYSKEYDOWN = 0x0104;<br />
     static public Int16 WM_SYSKEYUP = 0x0105;<br />
}<br />
<br />
delegate int HookProc(int code, IntPtr wParam, ref keyboardHookStruct lParam);<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]<br />
static extern IntPtr SetWindowsHookEx(HookType hook, HookProc callback, IntPtr hMod, uint dwThreadId);<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto,CallingConvention = CallingConvention.StdCall)]<br />
public static extern bool UnhookWindowsHookEx(int idHook);<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]<br />
static extern int CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, ref keyboardHookStruct lParam);<br />
<br />
[DllImport("kernel32.dll")]<br />
static extern IntPtr LoadLibrary(string lpFileName);<br />
<br />
public enum HookType : int<br />
{<br />
     WH_JOURNALRECORD = 0,<br />
     WH_JOURNALPLAYBACK = 1,<br />
     WH_KEYBOARD = 2,<br />
     WH_GETMESSAGE = 3,<br />
     WH_CALLWNDPROC = 4,<br />
     WH_CBT = 5,<br />
     WH_SYSMSGFILTER = 6,<br />
     WH_MOUSE = 7,<br />
     WH_HARDWARE = 8,<br />
     WH_DEBUG = 9,<br />
     WH_SHELL = 10,<br />
     WH_FOREGROUNDIDLE = 11,<br />
     WH_CALLWNDPROCRET = 12,<br />
     WH_KEYBOARD_LL = 13,<br />
     WH_MOUSE_LL = 14<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto,Pack=1)]<br />
public struct keyboardHookStruct<br />
{<br />
     public int vkCode;<br />
     public int scanCode;<br />
     public int flags;<br />
     public int time;<br />
     public int dwExtraInfo;<br />
}<br />
<br />
static IntPtr hooked = IntPtr.Zero;<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
     this.Hide();<br />
     IntPtr hInstance = LoadLibrary("User32");<br />
     hooked = SetWindowsHookEx(HookType.WH_KEYBOARD_LL,Form1.Hook, hInstance, 0);<br />
            <br />
}<br />
static string hookedstr;<br />
static string hookedDownStr;<br />
<br />
public static int Hook(int code, IntPtr wParam, ref keyboardHookStruct lParam)<br />
{<br />
<br />
     if (code < 0)<br />
     {<br />
          return CallNextHookEx(hooked, code, wParam, ref lParam);<br />
     }<br />
     if ((int)wParam == KeyPosition.WM_KEYDOWN)<br />
     {<br />
           hookedstr += "[D]";<br />
           hookedDownStr += ((Keys)lParam.vkCode).ToString() + " ";<br />
     }<br />
     hookedstr += ((Keys)lParam.vkCode).ToString() + " ";<br />
     return CallNextHookEx(hooked, code, wParam, ref lParam);<br />
     }<br />
<br />
     return 0;<br />
}

QuestionWorking with datagridview ? Pin
banghv9-Mar-08 18:23
banghv9-Mar-08 18:23 
GeneralRe: Working with datagridview ? Pin
Ravenet9-Mar-08 18:36
Ravenet9-Mar-08 18:36 
GeneralRe: Working with datagridview ? Pin
Christian Graus9-Mar-08 19:27
protectorChristian Graus9-Mar-08 19:27 
GeneralCAS, WPF & plugin question Pin
Super Lloyd9-Mar-08 18:15
Super Lloyd9-Mar-08 18:15 
Questionhow to display crystal reports at the client PC Pin
Sadaf Naeem9-Mar-08 18:07
Sadaf Naeem9-Mar-08 18:07 
GeneralRe: how to display crystal reports at the client PC Pin
Ravenet9-Mar-08 18:23
Ravenet9-Mar-08 18:23 
QuestionHow to clear all textboxes on a form with a button Pin
Jacob Dixon9-Mar-08 16:49
Jacob Dixon9-Mar-08 16:49 
AnswerRe: How to clear all textboxes on a form with a button Pin
KaptinKrunch9-Mar-08 16:57
KaptinKrunch9-Mar-08 16:57 
GeneralRe: How to clear all textboxes on a form with a button Pin
Jacob Dixon9-Mar-08 17:05
Jacob Dixon9-Mar-08 17:05 
GeneralRe: How to clear all textboxes on a form with a button Pin
KaptinKrunch9-Mar-08 17:10
KaptinKrunch9-Mar-08 17:10 
GeneralRe: How to clear all textboxes on a form with a button Pin
Jacob Dixon9-Mar-08 17:20
Jacob Dixon9-Mar-08 17:20 
GeneralRe: How to clear all textboxes on a form with a button Pin
Christian Graus9-Mar-08 17:35
protectorChristian Graus9-Mar-08 17:35 
GeneralRe: How to clear all textboxes on a form with a button Pin
Jacob Dixon9-Mar-08 17:42
Jacob Dixon9-Mar-08 17:42 
GeneralRe: How to clear all textboxes on a form with a button Pin
Christian Graus9-Mar-08 19:28
protectorChristian Graus9-Mar-08 19:28 
GeneralRe: How to clear all textboxes on a form with a button Pin
KaptinKrunch9-Mar-08 17:48
KaptinKrunch9-Mar-08 17:48 
AnswerRe: How to clear all textboxes on a form with a button Pin
Christian Graus9-Mar-08 17:41
protectorChristian Graus9-Mar-08 17:41 
GeneralRe: How to clear all textboxes on a form with a button Pin
Jacob Dixon9-Mar-08 17:48
Jacob Dixon9-Mar-08 17:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.