22.08.2010 23:36, Andrej Mitrovic wrote:
There's an example of a module constructor in TDPL. I don't think it's supossed 
to compile as it is, but I wanted to try it out anyway.

I need a way to call the windows c function GetVersionEx. A grep through the 
source files doesn't find it (except in the DMD cpp backend which it internally 
uses), but there's one GetVersion function in core\sys\windows\windows.d. That 
seems to work and returns a uint representation, but then I have to do 
bitmasking to get all the info out of it. Yikes!

The TDPL example does actually use GetVersionEx() and calls it with a 
"OSVERSIONINFOEX" structure argument, and it's all nicely documented on MSDN. 
But I've no idea if I can call it from D. Anyone doing Windows programming in D? :)


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Filtered-With-Copfilter: Version 0.84beta4 (ProxSMTP 1.8)
Copfilter-Filtered-With: SpamAssassin 3.2.5
Copfilter-Virus-Scanned: ClamAV 0.94.2
by Markus Madlener @ http://www.copfilter.org


Should be something like this:

---

import core.sys.windows.windows;

extern (System)
{

struct OSVERSIONINFOA
{
    DWORD dwOSVersionInfoSize;
    DWORD dwMajorVersion;
    DWORD dwMinorVersion;
    DWORD dwBuildNumber;
    DWORD dwPlatformId;
    char szCSDVersion[128];
}

struct OSVERSIONINFOW
{
    // same fields except for:
    wchar szCSDVersion[128];
}

alias OSVERSIONINFOA* LPOSVERSIONINFOA;
alias OSVERSIONINFOW* LPOSVERSIONINFOW;

BOOL GetVersionExA( LPOSVERSIONINFOA /lpVersionInfo/ );
BOOL GetVersionExW( LPOSVERSIONINFOW /lpVersionInfo <about:blank>/ );

}

---

With this declared, you should be able to call appropriate (Unicode/non-Unicode) version of this function. OSVERSIONINFOEX struct can be declared in a similar fashion.

Reply via email to