|
-
Nov 6th, 2001, 05:58 PM
#1
Thread Starter
Fanatic Member
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?
-
Nov 6th, 2001, 06:05 PM
#2
Thread Starter
Fanatic Member
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?
-
Nov 6th, 2001, 11:00 PM
#3
Frenzied Member
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.
-
Nov 7th, 2001, 06:44 AM
#4
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.
-
Nov 7th, 2001, 11:14 AM
#5
Thread Starter
Fanatic Member
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?
-
Nov 7th, 2001, 12:35 PM
#6
Monday Morning Lunatic
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
-
Nov 7th, 2001, 05:11 PM
#7
Thread Starter
Fanatic Member
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?
-
Nov 7th, 2001, 05:15 PM
#8
Monday Morning Lunatic
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
-
Nov 7th, 2001, 05:27 PM
#9
Thread Starter
Fanatic Member
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?
-
Nov 7th, 2001, 05:31 PM
#10
Monday Morning Lunatic
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
-
Nov 7th, 2001, 05:50 PM
#11
Thread Starter
Fanatic Member
...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?
-
Nov 7th, 2001, 05:55 PM
#12
Monday Morning Lunatic
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
-
Nov 7th, 2001, 05:59 PM
#13
Thread Starter
Fanatic Member
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?
-
Nov 7th, 2001, 06:01 PM
#14
Monday Morning Lunatic
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
-
Nov 7th, 2001, 06:06 PM
#15
Thread Starter
Fanatic Member
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?
-
Nov 7th, 2001, 06:24 PM
#16
Monday Morning Lunatic
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
-
Nov 7th, 2001, 06:29 PM
#17
Thread Starter
Fanatic Member
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Nov 7th, 2001, 09:45 PM
#18
Frenzied Member
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
-
Nov 8th, 2001, 09:29 AM
#19
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|