Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 17, 2010 How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
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 |
August 17, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Connors | 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? > > Thanks this 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 |
August 17, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michal Minich | On Tue, 17 Aug 2010 22:01:06 +0000, Michal Minich wrote:
>> Do you care to give me the correct switches?
>>
>> Thanks
>
> this example does not shows console. Maybe you can simplify it. http://digitalmars.com/d/2.0/windows.html
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.
|
August 17, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Connors | 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. |
August 17, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michal Minich | Michal Minich Wrote:
> 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?
> >
> > Thanks
>
> this 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
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.
|
August 17, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael Parrott | 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 |
August 17, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Connors | On Tue, 17 Aug 2010 22:27:19 +0000, John Connors wrote:
> The console is still showing. Any ideas why?
try std.process.execvp
|
August 17, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michal Minich | 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. |
August 18, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Connors | 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
|
August 18, 2010 Re: How to avoid the console from apearing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | "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) > Issue #? |
Copyright © 1999-2021 by the D Language Foundation