Jump to page: 1 2
Thread overview
Windows startup docs are out of date
Jan 07, 2014
Manu
Jan 07, 2014
Adam D. Ruppe
Jan 07, 2014
Manu
Jan 07, 2014
Adam D. Ruppe
Jan 08, 2014
Manu
Jan 08, 2014
Adam D. Ruppe
Jan 08, 2014
Jacob Carlborg
Jan 08, 2014
Jacob Carlborg
Jan 08, 2014
Mike Parker
Jan 08, 2014
Jacob Carlborg
Jan 08, 2014
eles
Jan 08, 2014
Manu
Jan 08, 2014
Jacob Carlborg
Jan 08, 2014
Adam D. Ruppe
Jan 08, 2014
Jacob Carlborg
Jan 08, 2014
Adam D. Ruppe
Jan 08, 2014
Jacob Carlborg
Jan 08, 2014
Adam D. Ruppe
Jan 08, 2014
Mike Parker
Jan 08, 2014
Jacob Carlborg
January 07, 2014
http://dlang.org/windows.html

This doesn't work anymore. I don't know what the proper way to boot a Win32
app is.
Is it required to explicitly init the runtime?


January 07, 2014
On Tuesday, 7 January 2014 at 21:26:07 UTC, Manu wrote:
> This doesn't work anymore. I don't know what the proper way to boot a Win32 app is.

The easiest way is to just write a regular program with a main() instead of a WinMain. If you need the args, you can get them from functions like GetModuleHandle, GetCommandLine, etc.

> Is it required to explicitly init the runtime?

If you want to use WinMain directly, yes, use Runtime.initalize before doing anything else. But I say regular main is much easier.
January 07, 2014
On 8 January 2014 07:29, Adam D. Ruppe <destructionator@gmail.com> wrote:

> On Tuesday, 7 January 2014 at 21:26:07 UTC, Manu wrote:
>
>> This doesn't work anymore. I don't know what the proper way to boot a Win32 app is.
>>
>
> The easiest way is to just write a regular program with a main() instead of a WinMain. If you need the args, you can get them from functions like GetModuleHandle, GetCommandLine, etc.
>
>
>  Is it required to explicitly init the runtime?
>>
>
> If you want to use WinMain directly, yes, use Runtime.initalize before doing anything else. But I say regular main is much easier.
>

It complains and says to use rt_init(), and that exception handler thing is
gone.
I think that page needs to be updated by someone who knows how it should
look.


January 07, 2014
On Tuesday, 7 January 2014 at 21:37:05 UTC, Manu wrote:
> It complains and says to use rt_init(), and that exception handler thing is gone.

blargh, well Runtime.initialize() without args works too.

> I think that page needs to be updated by someone who knows how it should look.

Yeah, and it'd be good to add the note that doing your own WinMain isn't actually needed... and use MessageBoxW.
January 08, 2014
On 8 January 2014 07:43, Adam D. Ruppe <destructionator@gmail.com> wrote:

> On Tuesday, 7 January 2014 at 21:37:05 UTC, Manu wrote:
>
>> It complains and says to use rt_init(), and that exception handler thing
>> is gone.
>>
>
> blargh, well Runtime.initialize() without args works too.


It didn't work for me. Said it was deprecated... and to use rt_init().
Is there a difference? Why do Runtime.initialize() AND rt_init() both
exist? I don't like pointless aliases... I freak out that there's some
small difference that I don't understand.

 I think that page needs to be updated by someone who knows how it should
>> look.
>>
>
> Yeah, and it'd be good to add the note that doing your own WinMain isn't actually needed... and use MessageBoxW.
>

But yeah, it needs to be updated with the latest best practise.


January 08, 2014
On Wednesday, 8 January 2014 at 00:32:56 UTC, Manu wrote:
> It didn't work for me. Said it was deprecated... and to use rt_init().


Huh, the message I got is:
winmain.d(13): Deprecation: function core.runtime.Runtime.initialize is deprecated - Please use the overload of Runtime.initialize that takes no argument.

Maybe different dmd versions. Oh well.

> Is there a difference?

The source tells:

    static bool initialize()
    {
        return !!rt_init();
    }

/// C interface for Runtime.initialize, returns 1/0 instead of bool
extern(C) int rt_init();


So no real difference.

> Why do Runtime.initialize() AND rt_init() both exist?

idk
January 08, 2014
On 2014-01-07 22:25, Manu wrote:
> http://dlang.org/windows.html
>
> This doesn't work anymore. I don't know what the proper way to boot a
> Win32 app is.
> Is it required to explicitly init the runtime?

I started to think about this some more and I agree with Adam, just use a regular D main function.

-- 
/Jacob Carlborg
January 08, 2014
On 2014-01-07 22:29, Adam D. Ruppe wrote:

> The easiest way is to just write a regular program with a main() instead
> of a WinMain. If you need the args, you can get them from functions like
> GetModuleHandle, GetCommandLine, etc.

The runtime provides access to the command line arguments as well:

core.Runtime.args
core.Runtime.cArgs

http://dlang.org/phobos/core_runtime.html

-- 
/Jacob Carlborg
January 08, 2014
On 2014-01-08 01:32, Manu wrote:

> It didn't work for me. Said it was deprecated... and to use rt_init().
> Is there a difference? Why do Runtime.initialize() AND rt_init() both
> exist? I don't like pointless aliases... I freak out that there's some
> small difference that I don't understand.

rt_init() is to be used from C, so you don't have to bother with the D mangling. Runtime.initialize() is supposed to be used from D, you need to do something special about the boot process, which you normally doesn't.

-- 
/Jacob Carlborg
January 08, 2014
On 1/8/2014 6:29 AM, Adam D. Ruppe wrote:
> On Tuesday, 7 January 2014 at 21:26:07 UTC, Manu wrote:
>> This doesn't work anymore. I don't know what the proper way to boot a
>> Win32 app is.
>
> The easiest way is to just write a regular program with a main() instead
> of a WinMain. If you need the args, you can get them from functions like
> GetModuleHandle, GetCommandLine, etc.
>

The easiest way is to use main() and add this to the DMD command line:

/SUBSYSTEM:WINDOWS:5.01

This will give you a windowed app with no console popping up *and* the command line args are still stored in Runtime.args and passed to the main method just as they are in a console app.

Note that 5.01 is for 32-bit. 5.02 should be used when compiling for 64-bit.

« First   ‹ Prev
1 2