Getting a program run everywhere.

This is a discussion on Getting a program run everywhere. within the C Programming forums, part of the General Programming Boards category; So, at this point I have Code: #include <stdio.h> #include <stdlib.h> #include <iostream.h> #include <windows.h> #include <wininet.h> #include <time.h> #include ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    56

    Getting a program run everywhere.

    So, at this point I have

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.h>
    #include <windows.h>
    #include <wininet.h>
    #include <time.h>
    #include <conio.h>
    
    
    
    
    
    int main()
    {
    
    	
     int c;
     FILE *fp;
    	
       
    
       if ((fp = fopen("C:\\Documents and Settings\\Famliy\\Desktop\\loggerkey.txt", "wb")) == NULL)
       {
    	   printf("Cannot open file for writing");
    	   exit(EXIT_FAILURE);
       } 
    
    
      while ((c = getch()) != '~')
       {
    	  putchar(c);
    	  fputc(c, fp);
       }
       fclose(fp);
    
       return 0;
    } // main
    The problem is, the logger stops loggin after another program is clicked. So say if I ran the program, then internet explorer, whatever I type in the address bar of internet explorerer is not logged. Is there any input/output stream function that can deal with this?

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    56
    Thank You, I'll look into hooks. From what I am reading, when a hook is running, does that mean that the whatever is hooked is hooked to the program running?

  4. #4
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    When you install a system-wide hook, which is what you're interested in, you're installing executable instructions to which the operating system will pass certain messages before they are passed to their target processes. So your program will install a system-wide hook to intercept the messages you desire and you can send messages to your application from the hook in order to allow it to perform whatever actions you'd like for a given message.

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    56
    I understand, what you mean lucky, however, the whole procedure is complicated. I am only a beginner, I still don't understand exactly what to do get theses keyboard messges to my application. Lots of the functions for hooks are defined under things I have never seen before. Is there any simple way to implement a keyboard hook, at least so that a beginner can understand?

  6. #6
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    In short, the answer is no. Unfortunately there are a lot of very complicated things that cannot easily be understood by a novice. However, there are several tutorials and detailed explanations available online. Read a lot of them. This sounds like a good topic to write a tutorial about, so I may do so in the near future and make it available on my site. I'll inform you if/when I do, but until then just do research.

    Fyi, I wasn't explaining how to code what you're seeking. Rather, I was merely explaining to you how it works. Good luck.

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    What language are you writing? iostream.h is not a valid header in any language I know of, and certinaly not in C. I'm also confused as to what the topic has to do with the program? What does logging keys have to do with getting a program to run everywhere?

  8. #8
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Well technically systemwide hooks are a form of DLL injection which is injected into every single running process to resolve to your filter function. So, in some way, your program is running in every single programs process space (assuming this isn't WH_KEYBOARD_LL, which works somewhat differently). I should learn DLL injection better, pretty cool stuffs.

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    > loggerkey.txt"
    You again - read the rules, then move along to something else.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 02:30 PM
  2. Re-doing a C program to run in Win2000 or XP
    By fifi in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 05:32 PM
  3. Replies: 3
    Last Post: 07-11-2005, 03:07 AM
  4. plz help me run this program!!!
    By galmca in forum C Programming
    Replies: 8
    Last Post: 02-01-2005, 12:00 PM
  5. Cannot run program in background?
    By registering in forum Linux Programming
    Replies: 3
    Last Post: 06-16-2003, 05:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21