Get drive letters
drives: get-drives: does [read %/]
12382 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
drives: get-drives: does [read %/]
REBOL [] win-drive: context [ win-lib: load/library %kernel32.dll null-buff: func [ {Returns a null-filled string buffer of the specified length.} len [integer!] ][ head insert/dup make string! len #"^@" len ] int-struct: make struct! [ value [integer!] ] none ; If all the requested information is retrieved, ; the return value is nonzero. GetVolumeInformation: make routine! compose/deep [ RootPathName [string!] ;LPCTSTR address of root directory of the ; file system VolumeNameBuffer [string!] ;LPTSTR address of name of the volume VolumeNameSize [integer!] ;DWORD length of lpVolumeNameBuffer VolumeSerialNumber [struct! [(first int-struct)]] ;LPDWORD// address of volume serial number MaximumComponentLength [struct! [(first int-struct)]] ;LPDWORD ;// address of system's maximum ;// filename length FileSystemFlags [struct! [(first int-struct)]] ; LPDWORD// address of file system flags FileSystemNameBuffer [string!] ;LPTSTR // address of name of file system FileSystemNameSize [integer!] ;DWORD // length of FileSystemNameBuffer return: [integer!] ] win-lib "GetVolumeInformationA" get-volume-info: func [ {Returns a block with volume-name, serial number, max. filename length, flags, and file system name if successful; otherwise NONE.} /with root /local vol-name file-sys-name ser-num max-filename-length flags res ][ vol-name: null-buff 260 file-sys-name: null-buff 260 ser-num: make struct! int-struct [0] max-filename-length: make struct! int-struct [0] flags: make struct! int-struct [0] root: copy/part to-local-file either with [root][what-dir] 3 res: GetVolumeInformation root vol-name length? vol-name ser-num max-filename-length flags file-sys-name length? file-sys-name either res <> 0 [ reduce [trim vol-name ser-num/value max-filename-length/value flags/value trim file-sys-name] ][ none ] ] ] print mold win-drive/get-volume-info print mold win-drive/get-volume-info/with %/d/ print mold win-drive/get-volume-info/with %/e/ print mold win-drive/get-volume-info/with %/f/ ;print mold win-drive/get-volume-info/with %/a/ halt