Interesting tip...
Well, most of these posts are questions, but this one''s a tip. A while back, I was trying to figure out how to do the equivalent of the cls command for a MS-DOS console app. It turns out that you can emulate typing into the DOS shell with the system() function (in stdlib.h.) So, to do a screen clear, you''d go system("cls"). To start Notepad, you''d type system("start c:/windows/notepad.exe"). And on and on. Very useful. It seems, though, that using the cd command has no effect, so you must use _chdir() for this one.
lntakitopi@aol.com | http://geocities.com/guanajam/
Forgot to tell you, it works in Windows apps too.
lntakitopi@aol.com | http://geocities.com/guanajam/
lntakitopi@aol.com | http://geocities.com/guanajam/
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
the equivalent of the cls command in an msdos app?
memset((char*)0xb8000, 0, 4000);
hell of a lot faster than spawning a process
--
Float like a butterfly, bite like a crocodile.
memset((char*)0xb8000, 0, 4000);
hell of a lot faster than spawning a process
--
Float like a butterfly, bite like a crocodile.
--Float like a butterfly, bite like a crocodile.
Well, of course using it for cls is slow... the use I liked was that you could run programs and open files so easily.
lntakitopi@aol.com | http://geocities.com/guanajam/
lntakitopi@aol.com | http://geocities.com/guanajam/
As goltrpoat alluded to, that command spawns a copy of the command interpreter (COMMAND.COM), which then executes your command, and exits.
Under Windows, I believe you can use the ShellExecute() function. This is cool because you can open documents, if they have a registered filetype.
e.g., ShellExecute(HWnd,"Play","C:\Music.MP3",NULL,NULL,WS_MINIMIZED)
or
ShellExecute(HWnd,"Open","http://mywebsite.com",NULL,NULL,WS_MAXIMIZED)
I didn't know you could use system() under Windows. Weird. I wonder if it is just a wrapper of ShellExecute or..?
---
Edited to change "i.e." to "e.g."
Edited by - Cereal Killah on May 28, 2000 5:17:01 PM
Under Windows, I believe you can use the ShellExecute() function. This is cool because you can open documents, if they have a registered filetype.
e.g., ShellExecute(HWnd,"Play","C:\Music.MP3",NULL,NULL,WS_MINIMIZED)
or
ShellExecute(HWnd,"Open","http://mywebsite.com",NULL,NULL,WS_MAXIMIZED)
I didn't know you could use system() under Windows. Weird. I wonder if it is just a wrapper of ShellExecute or..?
---
Edited to change "i.e." to "e.g."
Edited by - Cereal Killah on May 28, 2000 5:17:01 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement