www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - importing executables

reply "Josh" <moonburntm gmail.com> writes:
I'm trying to make an installer application in D. I've checked 
with various hashes and the file it's outputting is different to 
the original, and therefore Windows is saying it's not a valid 
Win32 application. I'm sure it's me doing something wrong and not 
DMD's fault. Any help is appreciated.

Here's the code:

-----installer.d-----
import std.stdio;

immutable auto testFile = import("test.exe");

void main()
{
     File f = File("installDir\\test.exe", "w");
     f.write(testFile);
     f.close;
}
---------------------

-----test.d-----
import std.stdio;

void main()
{
     writeln("Hello World");
}
----------------

I'm compiling using:
dmd test.d
dmd installer.d -J%cd%

DMD is version 2.060, Windows 7 64 bit.
Sep 26 2012
parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 9/27/12, Josh <moonburntm gmail.com> wrote:
      f.write(testFile);
f.rawWrite(testFile); Works for me then.
Sep 26 2012