Win32API::Const - Access Win32 constants such as WM_CLOSE, HELP_CONTENTS, etc.
# # Access value of WM_CLOSE without importing it # use Win32API::Const; print "WM_CLOSE = ", Win32API::Const::WM_CLOSE(), "\n"; # # Import and access values of WM_CLOSE and HELP_CONTENTS # use Win32API::Const qw(WM_CLOSE HELP_CONTENTS); print "WM_CLOSE = ", WM_CLOSE(), "\n"; print "HELP_CONTENTS = ", HELP_CONTENTS(), "\n"; # # Import WM_CLOSE, along with all constants whose names start with WS_ or SE_ # use Win32API::Const qw(:WS_ WM_CLOSE :SE_); print "WM_CLOSE = ", WM_CLOSE(), "\n"; print "WS_MAXIMIZE = ", WS_MAXIMIZE(), "\n"; print "WS_MINIMIZE = ", WS_MINIMIZE(), "\n"; print "WS_OVERLAPPED = ", WS_OVERLAPPED(), "\n"; print "SE_SHUTDOWN_NAME = ", SE_SHUTDOWN_NAME(), "\n";
The Win32API::Const module allows you to access the values of Win32 constants by name. Almost 6,000 constants are included -- these were parsed from the egcs 1.1 header files: Defines.h, Messages.h, Errors.h, Base.h, and Sockets.h.
Constant names and values were parsed from the egcs 1.1 Win32 header files (egcs is the free GNU C/C++ compiler). You can download the Win32 version of egcs from <ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/>.
A full list of Win32 constants and their meanings can be found in the documentation for your Win32 C/C++ compiler or in the Microsoft Developer Network (MSDN).
To import a constant, specify its name on the
use line. For example, to import the constants
SE_SHUTDOWN_NAME, do this:
use Win32API::Const qw(WM_CLOSE SE_SHUTDOWN_NAME);
Then, you can get the value of the constant by calling it like a subroutine.
my $value = WM_CLOSE(); print "The value of WM_CLOSE is: $value\n";
If you want to import all Win32 constants that start with, let's say, "WM_", then place ":WM_" in the import list. For example:
use Win32API::Const qw(:WM_); print "The value of WM_CLOSE is: ", WM_CLOSE(), "\n"; print "The value of WM_HELP is: ", WM_HELP(), "\n";
You can import an individual constant and a range of constants on the same line. For example, let's say you wan to import all the constants that start with
HELP_, along with the constant named
use Win32API::Const qw(:WM_ SE_SHUTDOWN_NAME :HELP_);
The order you list stuff in the import list does not matter.
Note that importing
:WM is different than importing
:WM_ (note the trailing underscore). The former imports constants such as
WMSZ_BOTTOM, whereas the latter does not. It's up to you what you want to do.
You can still use a constant, even if you do not import it into your namespace -- heck, even if you do not import any constants into your namespace. Just call it like you would any subroutine, and specify the full Win32API::Const package name.
use Win32API::Const; print "WM_CLOSE = ", Win32API::Const::WM_CLOSE(), "\n";
Win32API::Const -- Basic API Constants Copyright (C) 1998 Brian Dellert: <email@example.com>, 206/689-6828, <http://www.applespider.com>
Constants parsed from the egcs 1.1 header files Defines.h, Messages.h, Errors.h, Base.h, & Sockets.h
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program (gpl.license.txt); if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.