Skip to content

Instantly share code, notes, and snippets.

@southly
Created June 24, 2009 13:35
Show Gist options
  • Save southly/135265 to your computer and use it in GitHub Desktop.
Save southly/135265 to your computer and use it in GitHub Desktop.
;;; -*- Mode: Lisp; Package: WINAPI -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
(require "foreign")
(require "wip/winapi"))
(in-package "winapi")
(*define-dll-entry BOOL GetVolumeInformation (LPCSTR LPSTR DWORD (DWORD *) (DWORD *) (DWORD *) LPSTR DWORD)
"kernel32" "GetVolumeInformationA")
(in-package "user")
(defun get-volume-name (root)
(let ((chunk (si:make-chunk 'string 256)))
(unless (eql 0 (winapi:GetVolumeInformation (si:make-string-chunk root) chunk (si:chunk-size chunk) 0 0 0 0 0))
(si:unpack-string chunk 0 (si:chunk-size chunk)))))
;; (get-volume-name "h:\\")
;; => "HD-PHCU2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment