Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: sizeof(structure)

From: greggirwin:mindspring at: 18-Sep-2003 22:48

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