;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: LW-WIN; Base: 10 -*- ;;; $Header: /usr/local/cvsrep/lw-win/specials.lisp,v 1.8 2008/03/30 17:40:34 edi Exp $ ;;; Copyright (c) 2008, Dr. Edmund Weitz. All rights reserved. ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package :lw-win) (defmacro define-win32-constant (name value &optional docstring) "Utility macro to make some Win32 constants accessible in Lisp. A simple documentation string based on NAME is automatically created if none was provided." (flet ((make-win32-name (name) "Assumes that the Lisp name is always generated by adding plus signs at both ends and replacing underlines with hyphens." (substitute #\_ #\- (string-trim '(#\+) name) :test 'char=))) `(defconstant ,name ,value ,(or docstring (format nil "A Lisp constant corresponding to the Win32 constant ~A." (make-win32-name name))))) ) ;; help the LispWorks IDE to find these definitions (define-form-parser define-win32-constant (name) `(,define-win32-constant ,name)) (define-dspec-alias define-win32-constant (name) `(defconstant ,name)) ;; setup correct indentation of DEFINE-WIN32-CONSTANT (editor:setup-indent "define-win32-constant" 2 2 4) (define-win32-constant +invalid-handle-value+ (make-pointer :address #xffffffff :type :void)) (define-win32-constant +generic-read+ #x80000000) (define-win32-constant +generic-write+ #x40000000) (define-win32-constant +generic-execute+ #x20000000) (define-win32-constant +generic-all+ #x10000000) (define-win32-constant +create-new+ 1) (define-win32-constant +create-always+ 2) (define-win32-constant +open-existing+ 3) (define-win32-constant +open-always+ 4) (define-win32-constant +truncate-existing+ 5) (define-win32-constant +file-attribute-readonly+ #x00000001) (define-win32-constant +file-attribute-hidden+ #x00000002) (define-win32-constant +file-attribute-system+ #x00000004) (define-win32-constant +file-attribute-directory+ #x00000010) (define-win32-constant +file-attribute-archive+ #x00000020) (define-win32-constant +file-attribute-device+ #x00000040) (define-win32-constant +file-attribute-normal+ #x00000080) (define-win32-constant +file-attribute-temporary+ #x00000100) (define-win32-constant +file-attribute-sparse-file+ #x00000200) (define-win32-constant +file-attribute-reparse-point+ #x00000400) (define-win32-constant +file-attribute-compressed+ #x00000800) (define-win32-constant +file-attribute-offline+ #x00001000) (define-win32-constant +file-attribute-not-content-indexed+ #x00002000) (define-win32-constant +file-attribute-encrypted+ #x00004000) (define-win32-constant +format-message-allocate-buffer+ #x00000100) (define-win32-constant +format-message-ignore-inserts+ #x00000200) (define-win32-constant +format-message-from-string+ #x00000400) (define-win32-constant +format-message-from-hmodule+ #x00000800) (define-win32-constant +format-message-from-system+ #x00001000) (define-win32-constant +format-message-argument-array+ #x00002000) (define-win32-constant +format-message-max-width-mask+ #x000000ff) (define-win32-constant +page-readonly+ #x02) (define-win32-constant +page-readwrite+ #x04) (define-win32-constant +page-writecopy+ #x08) (define-win32-constant +page-execute+ #x10) (define-win32-constant +page-execute-read+ #x20) (define-win32-constant +page-execute-readwrite+ #x40) (define-win32-constant +page-execute-writecopy+ #x80) (define-win32-constant +standard-rights-required+ #x000f0000) (define-win32-constant +section-query+ #x0001) (define-win32-constant +section-map-write+ #x0002) (define-win32-constant +section-map-read+ #x0004) (define-win32-constant +section-map-execute+ #x0008) (define-win32-constant +section-extend-size+ #x0010) (define-win32-constant +section-map-execute-explicit+ #x0020) (define-win32-constant +section-all-access+ (logior +standard-rights-required+ +section-query+ +section-map-write+ +section-map-read+ +section-map-execute+ +section-extend-size+)) (define-win32-constant +file-map-copy+ +section-query+) (define-win32-constant +file-map-write+ +section-map-write+) (define-win32-constant +file-map-read+ +section-map-read+) (define-win32-constant +file-map-all-access+ +section-all-access+) (define-win32-constant +file-map-execute+ +section-map-execute-explicit+) (define-win32-constant +color-inactivecaption+ 3) (define-win32-constant +color-window+ 5) (define-win32-constant +color-windowtext+ 8) (define-win32-constant +color-highlight+ 13) (define-win32-constant +color-highlighttext+ 14) (define-win32-constant +color-inactivecaptiontext+ 19) (define-win32-constant +locale-user-default+ #x400) (define-win32-constant +locale-ifirstdayofweek+ #x100C) (define-win32-constant +locale-sdayname1+ #x2a) (define-win32-constant +locale-sdayname2+ #x2b) (define-win32-constant +locale-sdayname3+ #x2c) (define-win32-constant +locale-sdayname4+ #x2d) (define-win32-constant +locale-sdayname5+ #x2e) (define-win32-constant +locale-sdayname6+ #x2f) (define-win32-constant +locale-sdayname7+ #x30) (define-win32-constant +locale-smonthname1+ #x38) (define-win32-constant +locale-smonthname2+ #x39) (define-win32-constant +locale-smonthname3+ #x3a) (define-win32-constant +locale-smonthname4+ #x3b) (define-win32-constant +locale-smonthname5+ #x3c) (define-win32-constant +locale-smonthname6+ #x3d) (define-win32-constant +locale-smonthname7+ #x3e) (define-win32-constant +locale-smonthname8+ #x3f) (define-win32-constant +locale-smonthname9+ #x40) (define-win32-constant +locale-smonthname10+ #x41) (define-win32-constant +locale-smonthname11+ #x42) (define-win32-constant +locale-smonthname12+ #x43)