Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C (http://www.programmingforums.org/forum60.html)
-   -   Making a C app run without a console (http://www.programmingforums.org/showthread.php?t=11956)

ibbrowne3 Nov 20th, 2006 6:08 PM

Making a C app run without a console
 
Hi, I've taken an open source small http server written in 'C' and added: port scanning (for finding an available port to run on), functionality for it to kick open a browser and terminate the server after the browser is closed.

The problem:

The executable opens a console window when executed.

My attempts:
  • I can use "FreeConsole()" to cause the console (cmd) window to disappear a split second after the executable is run.
  • I've tried importing the existing code into a Visual Studio Express C++ application, ensuring linker options and subsystem are correct.
  • I've considered porting the app to c++ in hopes that I can get somewhere with it at that point.
  • I've created a simple windowed app with the "ShowWindow()" function commented out, and tried wedging the code into the app.

At this point, I don't know what direction I should be heading. I am not very familiar with Windows programming at all. My goal is to run the executable so that no console window appears, ever.

If I have not supplied enough information, please ask me. I am trying to provide everything that is pertinent.

I have been using the microsoft "cl" complier and a text editor to develop the software. I've also been searching several ideas as to why I am having so much trouble.
Perhaps:
  • I must use Visual Studio to create a windows app that will run my program.
  • C cannot be used to create a console-less application.
  • I have angered the programming gods and must kill a goat.

Thanks in advance for any and all help.

niteice Nov 20th, 2006 6:25 PM

I think there's a code to AllocConsole() that you can get rid of, can we see the code?

DaWei Nov 20th, 2006 6:44 PM

Quote:

C cannot be used to create a console-less application.
You can forget that one as silly; of course it can.

Since you want a Windows app, I'd suggest you write it that way.

Goats are expensive; I typically use a bottom-of-the-line chicken.

Prm753 Nov 20th, 2006 10:22 PM

You can also take a gander at this: http://www.codeproject.com/win32/runsilent.asp

A quick Google search pulled that up. It might be a bit more effective to write the program as a Windows application, as DaWei said.

Sane Nov 20th, 2006 10:33 PM

Here is a method that does not require you to modify the existing source code in any manner. But only if you are willing to spend 3 minutes to download and install Dev-C++. It compiles C code as well, don't worry.

- Start a new "Console Application" project.
- Discard the automatically generated template code (you do not need this).
- Select from the drop menu: "Project -> Project Options".
- Click the "Compiler" tab.
- Choose "Linker" from the list on the left.
- Set "Do not create a console window" to "Yes".

DaWei Nov 20th, 2006 11:14 PM

You can also put that option in the makefile with gcc (as used in Dev-Cpp), but you might not want to get used to proprietary or compiler-specific thangys.

ibbrowne3 Nov 21st, 2006 1:27 PM

the code
 
Thanks for the help, but I'm still lost. Using the MinGW compiler supplied with Dev-C++, yields many errors. I've posted the code here:
http://www.auburn.edu/~allenbb/files/dhttpd.c

niteice Nov 21st, 2006 1:40 PM

Which errors?


All times are GMT -5. The time now is 1:27 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC