CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2010
    Posts
    38

    Changing Window Procedure

    Hi
    Is this code for changing an application's window procedure correct , cuz im having trouble with it

    Code:
    while(TRUE)
    	{
    	hwnd = GetForegroundWindow();
    	if((WNDPROC)GetWindowLong(hwnd,GWL_WNDPROC) != NULL)
    		OldWindowProc = (WNDPROC)GetWindowLong(hwnd,GWL_WNDPROC);
    	SetWindowLong(hwnd,GWL_WNDPROC,(LONG)fakeWinProc);
    	Sleep(5000);
    	}

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Changing Window Procedure

    cuz im having trouble with it
    What's the trouble ?

  3. #3
    Join Date
    Oct 2010
    Posts
    38

    Re: Changing Window Procedure

    well basically i want to log all keystroke events...
    From the debugger it is evident that i get the foreground window... (a call to showwindow(hwnd,SW_HIDE) works)
    But the keystroke events in wndproc are not logged.. And the value in the OldWndProc is always 0x0000000.

  4. #4
    Join Date
    Aug 2008
    Posts
    902

    Re: Changing Window Procedure

    Have you looked into SetWindowsHookEx? If a keyboard hook is what you want, then why not set it up the usual way?

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Changing Window Procedure

    Quote Originally Posted by vinayak4gargya View Post
    From the debugger it is evident that i get the foreground window... (a call to showwindow(hwnd,SW_HIDE) works)...
    But the keystroke events in wndproc are not logged.. And the value in the OldWndProc is always 0x0000000.
    I presume the said code is executed in some process other than the foreground window belongs to. Well, to do that correct, the new window procedure must reside in the window's process. Otherwise the quoted code makes no sense.


    well basically i want to log all keystroke events...
    Well basically they do that some other way...
    Best regards,
    Igor

  6. #6
    Join Date
    Oct 2010
    Posts
    38

    Re: Changing Window Procedure

    oooh thanks a lot! So i need to hook into a process first?? Could somebody please elaborate on 'hooking'.. Or link to an article probably?

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Changing Window Procedure

    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured