Hi Gregg.

Nice. Doesn't this belong in the Cookbook? I know, it's "simple examples 
for new users." But "new REBOL users" could be veteran C programmers ... 
And from the p.o.v. of a Windows programmer, this example is simple enough.

Take Care,
Elan

Gregg Irwin wrote:

>Hi Paul,
>
>PT> Yeah I actually tried that thinking the same but had no luck with it.  I get
>PT> a return value of 0 which denotes failure of the GetVersionEx function.
>
>The fixed char array will give you grief, if you haven't already dealt
>with them in structs. Here's a very quick hack for you, with credit to
>Pekr and Cyphre for the nifty trick of generating elements dynamically
>to emulate char arrays in structs.
>
>-- Gregg                         
>
>make-elements: func [name count type /local result][
>    if not word? type [type: type?/word type]
>    result: copy "^/"
>    repeat i count [
>        append result join name [i " [" type "]" newline]
>    ]
>    to block! result
>]
>
>kernel.dll: load/library %kernel32.dll
>
>OSVERSIONINFOEXA: make struct! OSVERSIONINFOEXA-def: compose/deep [
>    dwOSVersionInfoSize     [integer!]      ; DWORD
>    dwMajorVersion      [integer!]      ; DWORD
>    dwMinorVersion      [integer!]      ; DWORD
>    dwBuildNumber       [integer!]      ; DWORD
>    dwPlatformId        [integer!]      ; DWORD
>    (make-elements 'szCSDVersion 128 #"@")  ; TCHAR
>] none
>OSVERSIONINFOEXA/dwOSVersionInfoSize: length? third OSVERSIONINFOEXA
>
>GetVersionEx: make routine! compose/deep/only [
>    lpVersionInformation    [struct! (OSVERSIONINFOEXA-def)] ;LPOSVERSIONINFO
>    return:     [integer!]  ;BOOL
>] kernel.dll "GetVersionExA"
>
>get-version: has [res] [
>    res: GetVersionEx OSVERSIONINFOEXA
>    either 0 = res [none][OSVERSIONINFOEXA]
>]
>
>res: get-version
>print [
>    "Major:" res/dwMajorVersion newline
>    "Minor:" res/dwMinorVersion newline
>    "Build:" res/dwBuildNumber  newline
>    "Version:" to-string copy/part at third OSVERSIONINFOEXA 21 128
>]
>
>free kernel.dll
>
>  
>


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to