Discussion:
[Dev-C++] program with no window or console
Guillermo Gutierrez
2004-08-20 20:14:01 UTC
Permalink
How would I get a program to run without displaying a console or a window?
I just want it to do its thing and then pop up a message box with a message at the end.

My program does what I want it to do, but I don't want a console or window to appear.

Here is my code:
_____________________________________________
#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include <winbase.h>

using namespace std;

int main(int argc, char *argv[])
{
char* cFileToCopy = "Q:\\QA\\2004-08 RC1\\lp4.exe";
char* cDestination = "C:\\Documents and Settings\\ggutierrez\\Desktop\\lp4.exe";

cout<<"gonna copy:\n";
cout<<"this ->" << cFileToCopy<<endl;
cout<<"to this->" << cDestination<<endl;
system("PAUSE");

if (CopyFile(cFileToCopy, cDestination, false) == 0)
{
MessageBox(NULL, "File Copy Failed", "Error", MB_OK);
}
MessageBox(NULL, "Files Copied Successfully.", "Copy Complete", MB_OK);

system("PAUSE");
return 0;
}

any suggestions?

Guillermo Gutierrez
Market Scan Information Systems
Software Q.A. Supervisor
(818) 575-2000 x2427
***@marketscan.com
Per Westermark
2004-08-20 20:34:06 UTC
Permalink
How about making it a Windows application, i.e. using WinMain() instead of
main() as entry point. Then you won't get a console window.

By the way, in case the copy fails, your program display both message
boxes, i.e. the OK box too.

Also, there is no need to have a system("PAUSE") at the end of the
program. The message box is enough.

/Per W
Post by Guillermo Gutierrez
How would I get a program to run without displaying a console or a window?
I just want it to do its thing and then pop up a message box with a message at the end.
My program does what I want it to do, but I don't want a console or window to appear.
_____________________________________________
#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include <winbase.h>
using namespace std;
int main(int argc, char *argv[])
{
char* cFileToCopy = "Q:\\QA\\2004-08 RC1\\lp4.exe";
char* cDestination = "C:\\Documents and Settings\\ggutierrez\\Desktop\\lp4.exe";
cout<<"gonna copy:\n";
cout<<"this ->" << cFileToCopy<<endl;
cout<<"to this->" << cDestination<<endl;
system("PAUSE");
if (CopyFile(cFileToCopy, cDestination, false) == 0)
{
MessageBox(NULL, "File Copy Failed", "Error", MB_OK);
}
MessageBox(NULL, "Files Copied Successfully.", "Copy Complete", MB_OK);
system("PAUSE");
return 0;
}
any suggestions?
Guillermo Gutierrez
Market Scan Information Systems
Software Q.A. Supervisor
(818) 575-2000 x2427
Continue reading on narkive:
Loading...