- disable window display for automation server
- Posted by extrnh on March 13th, 2007
i have a visual c++ automation server (mfc dll) that links to a c
library. the server is called by an excel vba macro. when a system
function is called in the c library a blank command window is
displayed while the c logic is executing. this is from the windows
cmd.exe that is executed by the system function. i
need to prevent the window from being displayed and would prefer
doing so from the c++ code (may not get access to c library source).
any suggestions?
- Posted by Olof Lagerkvist on March 13th, 2007
extrnh wrote:
Not any good ones, but if you get access to the C library source and
that source actually calls CreateProcess() and not system() to start the
console program you can quite easily change it by adding the
DETACHED_PROCESS flag to the process creating flags. That may or may not
work since it means that the program will get no console at all and if
it does error checking when writing to the console (not many programs do
that) it will fail.
If you do not need to support earlier versions of Windows than Windows
2000 and don't get access to the C library source there is another
possibility, you can create a console window and hide it immediately.
The second program executed by the library code will inherit the hidden
console window and not display a new one.
This code will do that (it does not matter if this code is ran twice so
you can place it anywhere before the library calls):
AllocConsole();
ShowWindow(GetConsoleWindow(), SW_HIDE);
--
Olof Lagerkvist
ICQ: 724451
Web: http://here.is/olof
- Posted by extrnh on April 2nd, 2007
On Mar 13, 9:52 am, Olof Lagerkvist <n...@email.address> wrote:
Olof:
Thanks very much for the tip. However, the
ShowWindow(GetConsoleWindow(), SW_HIDE) does not hide the window, only
puts it in the background. I am able to modify the caption, change
the position, and change the z order with SW_ constants, but I cannot
hide the window. One thing that I noticed is that the allocated
console window command module is excel.exe, the console window command
module for the linked library system calls is cmd.exe.
The subsequent linked library system calls do use the console that is
allocated, so that is good news.
Roger
- Posted by Jim Langston on April 3rd, 2007
"extrnh" <extrnh@yahoo.com> wrote in message
news:1175517866.655122.98750@q75g2000hsh.googlegro ups.com...
If it was me, I would use VC++ .net 2003 and make a window program. Then
delete the code that makes the window. I know that a windowed program
doesn't have an attached console unless you create one.
I don't know what magic is involved, just what happens.
Also, you can create a .dll app, maybe that won't have a window or a
console.