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

[REBOL] Re: (No subject)Date: Sun, 25 Aug 2002 14:45:42 -0600

From: greggirwin::mindspring::com at: 25-Aug-2002 13:40

Hi Anton, << How do you make a routine given a declaration like this?: DWORD WNetGetLastError( LPDWORD lpError, // error code LPTSTR lpErrorBuf, // error description buffer DWORD nErrorBufSize, // size of description buffer LPTSTR lpNameBuf, // buffer for provider name DWORD nNameBufSize // size of provider name buffer );
I don't have header files installed to check return code values from the call, but the following code seems to work. Holler if it doesn't. --Gregg REBOL [] null-buff: func [ {Returns a null-filled string buffer of the specified length.} len [integer!] ][ head insert/dup make string! len #"^@" len ] trim-trailing-nulls: func [string /local s pos] [ if string = null-buff length? string [return copy ""] s: tail string until [ s: back s any [s/1 <> #"^@" head? s] ] copy/part string index? s ] ; load libraries user32: load/library %user32.dll mpr: load/library %/c/winnt/system32/mpr.dll WNetGetLastError: make routine! [ lpError [string!] ; return error code lpErrorBuf [string!] ; error description buffer nErrorBufSize [integer!] ; size of description buffer lpNameBuf [string!] ; buffer for provider name nNameBufSize [integer!] ; size of provider name buffer return: [integer!] ; either NO_ERROR or ERROR_INVALID_ADDRESS ] mpr "WNetGetLastErrorA" w-net-get-last-error: func [/local err-code err-desc net-provider result][ err-code: null-buff 4 err-desc: null-buff 256 net-provider: null-buff 256 result: WNetGetLastError err-code err-desc length? err-desc net-provider length? net-provider err-code: to-integer to-binary head reverse err-code reduce [result err-code trim-trailing-nulls err-desc trim-trailing-nulls net-provider] ] print mold w-net-get-last-error halt