Why is the Win32 boilerplate the way it is?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 30 08:19:38 PDT 2014


On Monday, 30 June 2014 at 15:14:24 UTC, Jeremy Sorensen wrote:
> documentation means "import core.sys.windows.windwos"

The Windows headers that come with D are pathetically minimal. 
You'll need to grab a more complete win32 header OR copy/paste 
the individual prototypes off MSDN and use them that way.

So add this to your D file after importing 
core.sys.windows.windows:

extern(Windows)
void GetStartupInfoA(STARTUPINFO*); // the pathetic druntime 
Windows headers define TCHAR as ascii, so we'll use the A version


And try compiling it. If it complains that STARTUPINFO is 
undefined too, copy its prototype in:

struct STARTUPINFO {
   DWORD  cb;
   LPTSTR lpReserved;
   LPTSTR lpDesktop;
   LPTSTR lpTitle;
   DWORD  dwX;
   DWORD  dwY;
   DWORD  dwXSize;
   DWORD  dwYSize;
   DWORD  dwXCountChars;
   DWORD  dwYCountChars;
   DWORD  dwFillAttribute;
   DWORD  dwFlags;
   WORD   wShowWindow;
   WORD   cbReserved2;
   LPBYTE lpReserved2;
   HANDLE hStdInput;
   HANDLE hStdOutput;
   HANDLE hStdError;
}


And that should make it work.


More information about the Digitalmars-d-learn mailing list