How to run console with a c++ application - c++

I need to run a console when the app starts (for debug, log, etc) without a .bat file.
I use the LCC compiler on Windows 7 x86.

Look at the console APIs in Windows, start with AllocConsole.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%28v=vs.85%29.aspx

Related

How to use Windows C++ AttatchConsole with Cygwin terminals

I have a c++ windows application that runs via a GUI. I made a CLI for it to automate some things and this works fine if I use
AllocConsole();
or even
AttachConsole(PID);
as long as it is attaching to a windows CMD terminal.
I want to attach to a Cygwin terminal so I can use Expect to automate some things, but attach console always fails here and results in errors when trying to write to it.
Does anyone know how to make a windows application attach to a Cygwin terminal like this?
Not all cygwin terminals use the windows console. If you are not using a windows console then AttachConsole simply will not help you.
In particular a mintty.exe terminal will not work with AttachConsole because it is not a windows console.

running exe in Linux

I have built a simple console application in c++ vs2010 that just displays one line of text. Is it possible to run this executable from the Release folder in Linux?
Say I put the Release folder on a thumb drive, open it on a linux machine?
I was under the impression that console application written in c++ could run in both windows in linux? how mislead am I?
a) You need to run the executable with wine and emulate a windows environment
- OR -
b) You need to compile your code for your Linux distribution.

AIR NativeProcess API

I use nativeprocess api in AIR to launch a c++ console app. The console app runs correctly but does not appear, but I want it to be visible and user be able to interact with it. How can I achieve that?
Instead of launching your executable directly, you'll need to launch your platform's terminal application (on Windows, that's CMD.exe, on OS-X it's Terminal.app, and on unix/linux it's xterm).
By default, the terminal application will run an interactive shell prompt, but you can use command-line arguments to tell it to execute any other program instead. In this case, you'll want to tell it to execute your C++ console application.
On Windows, this might look something like this:
CMD.exe /K C:\path\to\your\app.exe
on OS-X, it's a little more complicated. Here's a related S.O. post ( Running a command in a new Mac OS X Terminal window)

Application launch from c command in window OS

I want to make an console application of c which can run other applications (exe files). Kindly guide me how can I make it possible so that from my c code i can run other executable files in window OS.
You can use the CreateProcess Windows API function.

Debugging shell extension in Windows 7

I'm trying to debug shell extension (IContextMenu) in Windows 7 with Visual C++ 2008. I have set DesktopProcess=1 in the registry and set host app to explorer.exe. But when I start the debugger, it launches explorer.exe and then detaches from the process. DllMain of the shell extension isn't called.
The same code with exactly the same settings launched in debugger without any problems in Windows XP + Visual C++ 2008.
Any thoughts how to debug the shell extension in Win7?
I've found a nice workflow that I think is the fastest way to rapidly iterate the code-build-test cycle when developing shell extensions. The following should work on any Windows version.
First prepare - set the start program of your shell extension project to be c:\windows\explorer.exe and also set it to be the start-up project.
Then, whenever you want to debug your shell extension perform the following steps:
Click on the task bar and press Alt-F4 - this will bring up the shut down dialog
Press Ctrl-Alt-Shift-Escape - this combination will close explorer.
Use Alt-Tab to go back to Visual Studio and press F5 - explorer will now launch with the VS debugger attached to it from the very beginning.
When done, just stop the debugger session. This will kill the debugged instance of explorer and will also automatically start a normal instance of it. This will also unlock the shell extension DLL so that you can build it again.
Caveat on Vista and 7 - be sure to run the Visual Studio that you use for debugging in non-Administrator mode (non-elevated), so that the explorer is started in its usual non-elevated mode.
Try launching explorer and THEN attaching the debugger to it.
You could try putting a DebugBreak() call in your code. This should launch the just-in-time debugger at the call and give you an idea of what is going on.
You should take a look at gflags.exe, part of the standard debugging tools sdk. It's got all the options you need to configure (global)flags for any process startup/services/heap/pool-tagging/stacktrace's-on-allocation etc...
Debugging Explorer.exe is usually overkill for extensions that operate in a shell view.
I personally use a little app I made that hosts an instance of IExplorerBrowser similar to this example. If your IContextMenu item is not the default item then you can just use Notepad.exe and its open file dialog...