How to hide console window while opening hidden COM object using C++? - c++

I am new to C++ so please be gentle. So i created a small C++ script which will be a part of a larger program. It creates an invisible window and navigates to home. While that part is done, it always creates a console window when it finishes execution and then in less than a second it vanishes. What do i need to change in order to make the program work in a way that the console window won't open ?

Instead of compiling as a console application, compile as a windows desktop project. Then convert main to be WinMain

Related

Could not create process in borland compiler

when i run the project(debug-> Run) it is giving an error in a pop up box having message "Could not Create the process". The project is created using borland C++ 4.52.can any one help me.
Thanks in advance.......
check these instructions:
Run Your Program
From the Menu Bar: Debug-Run
This will launch a window and run your program in it. After it finishes the window will go inactive and you will probably have to close it manually by clicking the 'x' icon in the upper right corner.
If the present window is one not your source code window - for instance, it will probably be the Message window after compiling and/or linking the program - then you will get a "Could not create process." error. This is because you are trying to execute the contents of a window that doesn't contain a program. Select the source code window and try again.
Source: http://www.dragonwins.com/courses/ECE1021/STATIC/LESSONS/IntroToTurboC.htm#Run%20Your%20Program

Key logger wont record key strokes without console

I created a small basic key logger in C++. For some reason when I compile and run the program with the console displayed, it will record every key stroke I make in whatever program I am using such as a browser and store it in a text file. However when I make it so that it WON'T display a console window, it will not record anything and it's just a process in the background doing nothing. Here is the link to my code: http://pastebin.com/4wqQyLJ9
The function that is giving me trouble with hiding the console, is the Stealth() function. Any suggestions, tips or hints will be helpful.
Use this function , it works for me pretty well.
ShowWindow(GetConsoleWindow(), SW_HIDE);
Instead of hiding the window after the program starts, I solved this by not
having a window to begin with. Compile with -mwindows and a window is not
created when the program starts.
Example
I would consider a Windows Service for this kind of thing if you don't need UI. Also using GetAsyncKeyState can be more stealthy if required. This C++ source might be of use...
Windows Service Keylogger

Add console to existing MFC application

I'm working with 2 friends in a class project to make a D&D game. so far for the assignments I've been doing character creation stuff and strutting on the command line.
Now we're bringing or part together and I need to output ny dice rolls on a console and a few things on another one that will have to become the main view or tab or whatever it's called when it requires input/attention.
Problem is I never learned MFC yet because I didn't need it. How hard would it be to make a sample MFC console all that I can give to the teammate in charge of the GUI?
Could anyone point me to some instruction on making a console for an MFC app and how to give it output and receive output?
First, you can't. for both Unix/Linux and Windows, there is a one console/process limit. If you want another console, you have to create another process, that writes and reads the other console, while you send and receive the data.
You can use a NamedPipe http://msdn.microsoft.com/en-us/library/windows/desktop/aa365590%28v=vs.85%29.aspx to send data between processes, and the CreateProcess() function lets you create a process with a separate Console window.
Alternatively you can just write a Console-Look-a-Like window in some GUI.

Can you create a start-up window in console program?

I want to a create dialog box like window before displaying the console window. I haven't actually tried anything yet but was just wondering if it can be displayed as a start-up window.
If you compile your win32 application as a console app, the console window will appear before you get a chance to do anything else.
To get around this, you need to use a windows application - this won't display a console window at all by default. Some time after startup you can then call AllocConsole to create a console window.
I'm not sure, but if it's a windowed application already, it might be worth making your own console window to redirect standard IO. It'll certainly look nicer. If you want the exact behavior of the regular console, such as the same copy/paste, you'd have to reimplement it.

How to make a console program doesn't have console window

I'm writing a console program.
The program doesn't print anything.
So, it doesn't need to a console window.
I tried to call FreeConsole() function at program starting point.
When I execute the program from windows explorer, a console window appears and then disappears.
But I wish the console window never appears.
How can I do that?
Thanks in advance.
If you are using Visual Studio .Net then create a normal console application and change the output type to Windows application.
Use WinMain instead of main as your program's entry point: WinMain at MSDN