Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Edit Report
system() function Posted by Justin on 8 Sept 2000 at 8:04 PM
I was wondering if anyone knows a way to use the system function (or any function that would be like entering a command in the DOS prompt) from a Windows application and not have it bring up DOS prompt while the command is executing? If it makes a difference, the application is probably only going to be used on computers with Win98.<br>
<br>
Thanks in advance,<br>
Justin


Edit Report
Re: system() function Posted by *unknown* on 8 Sept 2000 at 11:46 PM
Yes there is, it's called Console Applications. There are a bunch of API's for a<br>
console app (i.e. WriteConsole, ect.).<br>
<br>
You can get there structions in the Win32 Programmers Reference. I'm assuming<br>
that you do not have it, otherwise, you probally wouldn't have asked that question.<br>
<br>
Hope that helped,<br>
*unknown*<br>
<br>
P.S. I included a link that will download it for you. It's about 5 megs.


URL:http://www.multimania.com/crimstuff/win32.zip

Edit Report
Re: Re: system() function Posted by Justin on 9 Sept 2000 at 2:02 PM
I guess my question wasn't very clear. What I am trying to do is get a GUI Windows application (one that normaly uses WinMain as opposed to main) to use the system function without displaying a console window. I've also already tried using the Windows API console functions, but whenever I call AllocConsole, it shows the console window too.<br>
<br>
Justin


Edit Report
Re: Re: Re: system() function Posted by KMS on 10 Sept 2000 at 6:03 PM
Hello Justin,<br>
<br>
I have no compiler in this machine (I installed Visual Studio 7 beta over VC++ 5.0 and neither is working :) but what would happen if you run a console app with CreateProcess with SW_HIDE? You can easily get the console window handle with EnumThreadWindows maybe and WM_CLOSE or DestroyWindow it. <br>
<br>
If that works, then maybe you can write a simple console app that receives the actual "dos" command through the command line and run that.<br>
<br>
Just a thought.<br>
<br>
: I guess my question wasn't very clear. What I am trying to do is get a GUI Windows application (one that normaly uses WinMain as opposed to main) to use the system function without displaying a console window. I've also already tried using the Windows API console functions, but whenever I call AllocConsole, it shows the console window too.<br>
: <br>
: Justin<br>
: <br>
<br>



Edit Report
Re: system() function Posted by Sunlight on 10 Sept 2000 at 7:10 PM
You can specify the CREATE_NO_WINDOW flag in CreateProcess under Windows NT. The DETACHED_PROCESS flag may also have the same effect, and would be more portable.<br>
<br>
Sunlight


Edit Report
Re: Re: system() function Posted by Justin on 13 Sept 2000 at 2:04 PM
Thanks to everyone who replied, I've gotten it working now. I ended up using KMS's method of calling CreateProcess using SW_HIDE in the STARTUPINFO paramiter to execute a console app I wrote that passes its command line to the system() function.<br>
<br>
My biggest problem was waiting for the command to complete before doing anything else, which I finally got done by waiting for GetExitCodeProcess to stop giving me STILL_ACTIVE in a while loop. I didn't seem to need to use EnumThreadWindows or DestroyWindow, it seems the console app automatically closes when it finishes executing.<br>
<br>
Thanks Again,<br>
Justin


Edit Report
Re: system() function Posted by Stoic Joker on 12 Sept 2000 at 4:18 PM
Greetings<br>
I could be way of base, but... I recently wrote a<br>
dialog based GUI loader for Win2k SP1 to handle all the commandline switches etc. useing the ShellExecute() function with seperate buffers for the target .exe & commandline switches. if you think it might help I'll Email the source/project file to you.<br>
<br>
Stoic Joker<br>
<br>
: I was wondering if anyone knows a way to use the system function (or any function that would be like entering a command in the DOS prompt) from a Windows application and not have it bring up DOS prompt while the command is executing? If it makes a difference, the application is probably only going to be used on computers with Win98.<br>
: <br>
: Thanks in advance,<br>
: Justin<br>
: <br>
<br>



Report
Re: system() function Posted by Christinme7890 on 9 Apr 2001 at 3:02 PM
: I was wondering if anyone knows a way to use the system function (or any function that would be like entering a command in the DOS prompt) from a Windows application and not have it bring up DOS prompt while the command is executing? If it makes a difference, the application is probably only going to be used on computers with Win98.
:
: Thanks in advance,
: Justin
:
:
the system function should work. you need to include dos.h and the system function arguements are just a string. the string is what you want the dos shell to do. the shell does not show or at least should not show.

Report
Re: system() function Posted by wael_tahon on 15 Apr 2001 at 12:31 AM
Take this i try it my self
(1) from inside your program make a batch file containing all
the DOS commands you want and name it "c:\c.bat"
use fopen,fwrite,fclose so simple.

(2) make a new Win32 program and call it "t.exe" and put this code on it.

#include <winbase.h>
#include <windows.h>
#include<stdlib.h>

int PASCAL WinMain(HINSTANCE hCurInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
SetWindowLong(/*your App handle*/, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
system("c:\\c.bat");
return 0;
}

(3) Execute this program from inside your main program like this

WinExec("t.exe",SW_HIDDEN);


Gooooooooood bye




Report
Re: system() function Posted by wael_tahon on 14 Apr 2001 at 6:12 AM
Use
#include<winbase.h>
then:
WinExec("Full path with arguments",SW_HIDDEN);

Ha ha ha hooooooooooooooo




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.