digitalmars.D.learn - How to avoid the console from apearing.
- John Connors (14/14) Aug 17 2010 Hi.
- Michal Minich (8/31) Aug 17 2010 this example does not shows console. Maybe you can simplify it.
- Michal Minich (4/10) Aug 17 2010 It was mentioned on NG that you don't need anymore WinMain and initializ...
- Michael Parrott (7/42) Aug 17 2010 If you look on that page, you'll see:
- John Connors (36/36) Aug 17 2010 My small loader is not so small anymore. I've modified it according to t...
- Michal Minich (2/3) Aug 17 2010 try std.process.execvp
- John Connors (4/4) Aug 17 2010 That worked. Thanks.
- Yao G. (15/19) Aug 17 2010 Try using WinMain instead of main:
- Steven Schveighoffer (12/27) Aug 17 2010 The console is appearing because of the way you are starting the child
- Nick Sabalausky (3/5) Aug 18 2010 Issue #?
- Lars T. Kyllingstad (2/10) Aug 18 2010 3979
Hi. This is my entire program: import std.process: system; int main(string[] argv) { return system(r"bin\someprogram.exe"); } It works but a console (from my program) apears while someprogram.exe is running. I've read that some optlink switches are needed to make the console disapear. Tried the following (which I found in DM FAQ), but don't seem to work: dmd -L/exet:nt/su:windows loader.d resource.res The console keeps appearing. Do you care to give me the correct switches? Thanks
Aug 17 2010
On Tue, 17 Aug 2010 21:40:02 +0000, John Connors wrote:Hi. This is my entire program: import std.process: system; int main(string[] argv) { return system(r"bin\someprogram.exe"); } It works but a console (from my program) apears while someprogram.exe is running. I've read that some optlink switches are needed to make the console disapear. Tried the following (which I found in DM FAQ), but don't seem to work: dmd -L/exet:nt/su:windows loader.d resource.res The console keeps appearing. Do you care to give me the correct switches? Thanksthis example does not shows console. Maybe you can simplify it. http://digitalmars.com/d/2.0/windows.html in step 3 you need to crate mydef.def file and give it as an argument to compiler. you will probably not need, but complete docs are here http://www.digitalmars.com/ctg/ctgDefFiles.html http://www.digitalmars.com/ctg/win32programming.html
Aug 17 2010
On Tue, 17 Aug 2010 22:01:06 +0000, Michal Minich wrote:It was mentioned on NG that you don't need anymore WinMain and initialize runtime manually - that only 'main' is sufficient, but I did not tested it.Do you care to give me the correct switches? Thanksthis example does not shows console. Maybe you can simplify it. http://digitalmars.com/d/2.0/windows.html
Aug 17 2010
Michal Minich Wrote:On Tue, 17 Aug 2010 21:40:02 +0000, John Connors wrote:If you look on that page, you'll see: 3. A .def (Module Definition File) with at least the following two lines in it: EXETYPE NT SUBSYSTEM WINDOWS Without those, Win32 will open a text console window whenever the application is run. So I'm assuming that is the answer.Hi. This is my entire program: import std.process: system; int main(string[] argv) { return system(r"bin\someprogram.exe"); } It works but a console (from my program) apears while someprogram.exe is running. I've read that some optlink switches are needed to make the console disapear. Tried the following (which I found in DM FAQ), but don't seem to work: dmd -L/exet:nt/su:windows loader.d resource.res The console keeps appearing. Do you care to give me the correct switches? Thanksthis example does not shows console. Maybe you can simplify it. http://digitalmars.com/d/2.0/windows.html in step 3 you need to crate mydef.def file and give it as an argument to compiler. you will probably not need, but complete docs are here http://www.digitalmars.com/ctg/ctgDefFiles.html http://www.digitalmars.com/ctg/win32programming.html
Aug 17 2010
My small loader is not so small anymore. I've modified it according to the sample but the console is still showing: import core.runtime; import std.c.windows.windows; import std.process: system; extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int result; void exceptionHandler(Throwable e) { throw e; } try { Runtime.initialize(&exceptionHandler); result = system(r"bin\someprogram.exe"); Runtime.terminate(&exceptionHandler); } catch (Object o) // catch any uncaught exceptions { MessageBoxA(null, cast(char*)o.toString(), "Error", MB_OK | MB_ICONEXCLAMATION); result = 0; // failed } return result; } NOTE: The sample on the website doesn't compile because exceptionHandler() should receive a Throwable not an Exception. I then added a loader.def file that looks like this: EXETYPE NT SUBSYSTEM WINDOWS And to compile I'm using this line: dmd loader.d loader.def resource.res The console is still showing. Any ideas why? Thanks
Aug 17 2010
On Tue, 17 Aug 2010 22:27:19 +0000, John Connors wrote:The console is still showing. Any ideas why?try std.process.execvp
Aug 17 2010
That worked. Thanks. Still wonder why execvp with a simple main() (someprogram.exe is not executed). But for now the WinMain() version will do. Thanks again.
Aug 17 2010
On Tue, 17 Aug 2010 16:40:02 -0500, John Connors <JohnConnors mailinator.com> wrote:[snip] It works but a console (from my program) apears while someprogram.exe is running. I've read that some optlink switches are needed to make the console disapear.Try using WinMain instead of main: --- import core.runtime; import std.c.windows.windows, std.process; extern(Windows) int WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) { return system( r"bin\someprogram.exe" ); } --- -- Yao G.
Aug 17 2010
On Tue, 17 Aug 2010 17:40:02 -0400, John Connors <JohnConnors mailinator.com> wrote:Hi. This is my entire program: import std.process: system; int main(string[] argv) { return system(r"bin\someprogram.exe"); } It works but a console (from my program) apears while someprogram.exe is running. I've read that some optlink switches are needed to make the console disapear. Tried the following (which I found in DM FAQ), but don't seem to work: dmd -L/exet:nt/su:windows loader.d resource.res The console keeps appearing. Do you care to give me the correct switches?The console is appearing because of the way you are starting the child process. I don't think the linker flags passed to the loader have any bearing on what happens when you execute a child process. Changes are afoot to std.process, we recently got a blocker fixed (not yet in svn, but someone submitted a correct patch) so I can finish my Windows version. This will include a 'gui' flag that allows you to suppress the console. I don't know if the gui flag will be available on the 'system' function, but you should be able to easily run a program with the new std.process functions. -Steve
Aug 17 2010
"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message news:op.vhl46mdneav7ka localhost.localdomain...Changes are afoot to std.process, we recently got a blocker fixed (not yet in svn, but someone submitted a correct patch)
Aug 18 2010
On Wed, 18 Aug 2010 13:50:34 -0400, Nick Sabalausky wrote:"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message news:op.vhl46mdneav7ka localhost.localdomain...3979Changes are afoot to std.process, we recently got a blocker fixed (not yet in svn, but someone submitted a correct patch)
Aug 18 2010