program's executions

This is a discussion on program's executions within the Windows Programming forums, part of the Platform Specific Boards category; Is it possiable for me to create a program that once the user clicks on the x (you know top ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    program's executions

    Is it possiable for me to create a program that once the user clicks on the x (you know top right corner of every programm)
    and the programm close's for it to execute agian? untill the required input is inserted in to the programm? cause im tring to create a password protection for some of my progs
    Only the strong survives.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    How about not closing it if the X is pressed? Reset the fields instead or whatever you want to do.
    It is the WM_CLOSE message, but you probably knew that.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    In MFC you can override virtual void CWnd::OnCancel(); and as Magos said, handle the WM_CLOSE message.
    The way I normally do this is:
    Code:
    // header
    public:
      virtual void OnCancel() { OnClose(); }
    Code:
    // implementation
    void CDlg::OnClose() {
      // do stuff here and don't call the next line
      // if you don't want the dialog to close
    
      CDialog::EndDialog(IDCANCEL);
    }

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    err hehe sorry.. but im kinda new on c.. i was learning php and its a bit simular.. but... see im tring to put something like that in to something like this...


    Code:
    #include <stdio.h>
    #include <conio.h>
    
    int main( ){
      char password[] = "admin";
      int times;
      char *fp;
      
      for(times=1; times<=3; times++){
      
         printf("Please enter password to proceed\n");
         scanf("%s",password);
        
      if(!strcmp(password,"admin") == 0 || !strcmp(password,"admin") == NULL){
       printf("\tWrong password\n", password, system("cls"));
       getch();
       
     }else{
    
           printf("\tBoom Your Dead\n", password, times, system("cls"));
           getch();
           return 0;   
           }
      } 
    }
    I still dont get what you mean.. is there a tut on this someware that i can go and read on it.. thanx
    Only the strong survives.

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    I see...
    Well, AFAIK there is no way to handle such console events. What we were talking about was the Win API. You're doing a console application, and that window isn't exactly part of your program, it's only a tool for running console applications.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    Oh see im tring to create this password prog so no one else can get in to my system hehe.. anyways.. any suggestions?
    Only the strong survives.

  7. #7
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Suggestions? Yeah. Do it with a win32 app. : )

  8. #8
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by xlordt
    Oh see im tring to create this password prog so no one else can get in to my system hehe.. anyways.. any suggestions?
    I may be missing something here, but how does that stop someone from doing something else? You just Alt-Tab. Or is this pure DOS?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  9. #9
    Addicted to the Internet netboy's Avatar
    Join Date
    Dec 2001
    Posts
    158
    Just disable the X button in the VB form properties.
    It's unfulfilled dreams that keep you alive.

    //netboy

  10. #10
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by netboy
    Just disable the X button in the VB form properties.
    VB? This is a C forum...

    Also, since he uses printf I believe he's doing a console app.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  11. #11
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Hate to break it to you but you'd also have to intercept ctrl alt delete.

  12. #12
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Originally posted by Magos
    I may be missing something here, but how does that stop someone from doing something else? You just Alt-Tab. Or is this pure DOS?
    BTW, this can be blocked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 06:32 AM
  2. Newbie question: pointers, other program's memory
    By xxxxme in forum C++ Programming
    Replies: 23
    Last Post: 11-25-2006, 12:00 PM
  3. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  4. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 04:42 AM
  5. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 03:12 AM

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