stopping the console window from showing
Matthew Luckie
kluckie@ihug.co.nz
Mon Sep 24 22:01:00 GMT 2001
Hi there
I use XWin.exe to do remote X with the following shortcut:
C:\cygwin\usr\X11R6\bin\XWin.exe -screen 0 1024x740 -from
192.168.0.10 -query
192.168.0.1 -once -emulate3buttons -nowinkill -nounixkill
I have the path environment set so I can do this from a shortcut on my
desktop. I absolutely love what I can do with this software, although it
would be nice to get rid of the console window that is shown along with the
Cygwin/XFree86 window.
I am aware that NT Emacs overcame this problem with a small utility exe that
hides the console window that is created. I adapted the code to XWin.exe
(called it runxwin.exe) although the Cygwin/XFree86 window never shows.
This could be my fault. I haven't looked through the code for XWin.exe but
I speculate that this could be the result of ShowWindow being called with
WinMain's nCmdShow which would be SW_HIDE.
I have included the source to the runxwin.exe which was adapted from
runemacs.exe (which is GPLd).
http://www.math.luc.edu/~rig/home/emacs/emacs-20.4/nt/runemacs.c
Is there a way for me to stop the console window showing?
If you respond, could you please CC me as I am not subscribed to this list
Matthew
#include <windows.h>
#include <string.h>
#include <malloc.h>
int WINAPI WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int
nShow)
{
STARTUPINFO start;
SECURITY_ATTRIBUTES sec_attrs;
PROCESS_INFORMATION child;
int wait_for_child = FALSE;
DWORD ret_code = 0;
char *new_cmdline;
char *p;
char modname[MAX_PATH];
if (!GetModuleFileName (NULL, modname, MAX_PATH))
goto error;
if ((p = strrchr (modname, '\\')) == NULL)
goto error;
*p = 0;
new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 1);
strcpy (new_cmdline, modname);
strcat (new_cmdline, "\\XWin.exe ");
strcat (new_cmdline, cmdline);
memset (&start, 0, sizeof (start));
start.cb = sizeof (start);
start.dwFlags = STARTF_USESHOWWINDOW;
start.wShowWindow = SW_HIDE;
sec_attrs.nLength = sizeof (sec_attrs);
sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = FALSE;
if (CreateProcess (NULL, new_cmdline, &sec_attrs, NULL, TRUE, 0,
NULL, NULL, &start, &child))
{
if (wait_for_child)
{
WaitForSingleObject (child.hProcess, INFINITE);
GetExitCodeProcess (child.hProcess, &ret_code);
}
CloseHandle (child.hThread);
CloseHandle (child.hProcess);
}
else
goto error;
return (int) ret_code;
error:
MessageBox (NULL, "Could not start XWin.", "Error", MB_ICONSTOP);
return 1;
}
More information about the Cygwin-xfree
mailing list