C#: How can I hide when you start other programs in C# using Win32API? -
i'm using code:
/********** code first way **********/ string filepath = "ex"; stratinfo psi = new startinfo(filepath); psi.windowstyle = processwindowstyle.hidden; process process = process.start(psi); process.waitforinputidle(); /********************************************/ /********** code second way **********/ string filepath = "ex"; process process = process.start(new startinfo(filepath)); process.waitforinputidle(); [dllimport("user32.dll")] private static extern int showwindow (int hwnd, int ncmdshow); int hwnd = findwindow(null, "main caption"); if (hwnd != 0) { showwindow(hwnd, 0); } /***********************************************/
most of programs in way, solved problem.
however, programs have not worked way.
the first way : not possible @ all.
the second way : part, , slow. can hide main window. messagebox still displayed.
how resolve problem? thank answer.
check out winexec function, lets pass visibility parameter:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687393(v=vs.85).aspx
this may give similar results process, however, it's worth experimenting with.
you mention messageboxes showing - can't control that, because program running in desktop has ability wants desktop, including popping random topmost windows.
try running program service: (this supresses program's ui):
http://www.howtogeek.com/50786/using-srvstart-to-run-any-application-as-a-windows-service/
of course, now, when messagebox raised program, windows doesn't display it, program 'locked up' there; , may not have permissions run program service.
why want this, exactly? might suprised @ workarounds community suggests.
good luck anyway.
Comments
Post a Comment