Results 1 to 19 of 19

Thread: launchin an external program

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    launchin an external program

    for example, i have

    Code:
    #include<stdio.h>
    #include<windows.h>
    
    void main(int argc, char *argv[]){
    	ShellExecute(NULL,"open","ping.exe","10.0.0.2","",4);
    }
    i want it to launch in the same window, i think i'd do that by instead of putting "NULL" for the handle, i put the handle for my app...but how do i get that? does c++ have an app.<x> for the console?

    thanks
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  2. #2

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    i also need it because i wanna use the SetTimer() and KillTimer()

    thanks again
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  3. #3
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    I don't think it's possible to load another program into the same
    console. The hwnd is mainly for actual windows created with
    CreateWindow(Ex)(..) so that it will be the parent that receives
    messages from the child window such as errors. The hwnd in
    such a case would only refer to the console and not your actual
    application. I would suggest using an actual windows application.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Windows timers send messages. I'm not sure if you can get messages in a console app...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    i know they send messages, ill do:

    SetTimer(<hwnd>,1000,0, AddressOf(TimerProc);

    .
    .
    .
    void TimerProc(<parameters>);
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Console programs ARE windows programs.

    They just have an extra bit of code to create a console-style window and direct the input accordingly. If you've got the CRT source then have a look, it's quite interesting.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    parksie - do you know how-to get the handle?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    To what? The window? If you didn't create a window then you can't really. Although you could create a window specifically for it.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    how would i go about doing that?

    vc++6

    i dont know too much c++, i know upto pointers & classes
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    If you're new to C++, then just stick with system("ping")
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    ...but i wanna use the timer
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Ah. Are you trying to make a keepalive program? You could do something like:
    Code:
    #include <windows.h>
    #include <stdlib.h>
    
    int main() {
        for(;;) {
            system("ping.exe 10.0.0.2");
            Sleep(1000); // However many milliseconds between runs
        }
    
        return 0;
    }
    Obviously you'd have to put something in to check for a keypress to quit but I'll leave that as an exercise for the reader
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    well actually, the ping was just an example, i was wondering if it would work in the same window..

    what i really need though is the Timer stuff...

    thanks tho
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    For accuracy within about 30milliseconds, just call SetTimer using a callback function as given earlier You don't need a window for that.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  15. #15

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    so i just need to set the handle to "NULL" ?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  16. #16
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yep. Do a search for SetTimer on Google and that should give you plenty of reference info
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  17. #17

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    okidokey, thanks alot!
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  18. #18
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Originally posted by parksie
    Console programs ARE windows programs.

    They just have an extra bit of code to create a console-style window and direct the input accordingly. If you've got the CRT source then have a look, it's quite interesting.
    I was referring to an actual window created with CreateWindow.
    You can't really call console apps "windows" programs if they
    don't need a window (or Windows) to run.
    Ex: void main(){blah; blah;} can be compiled and run from unix
    or dos without a window.

    just my 2 cents

  19. #19
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    but if the program is compiled as console app with vc++ it is a real windows program. It always depends on the runtime library...

    You could get the window handle by calling SetConsoleTitle to set the window caption, then call FindWindow on it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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