This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Win32-0.31
[perl5.git] / ext / Win32 / Win32.pm
CommitLineData
b4ad57f4
NC
1package Win32;
2
3BEGIN {
4 use strict;
34f7f30d 5 use vars qw|$VERSION $XS_VERSION @ISA @EXPORT @EXPORT_OK|;
b4ad57f4
NC
6
7 require Exporter;
8 require DynaLoader;
9
10 @ISA = qw|Exporter DynaLoader|;
0130bfd9 11 $VERSION = '0.31';
34f7f30d
SH
12 $XS_VERSION = $VERSION;
13 $VERSION = eval $VERSION;
b4ad57f4
NC
14
15 @EXPORT = qw(
16 NULL
17 WIN31_CLASS
18 OWNER_SECURITY_INFORMATION
19 GROUP_SECURITY_INFORMATION
20 DACL_SECURITY_INFORMATION
21 SACL_SECURITY_INFORMATION
22 MB_ICONHAND
23 MB_ICONQUESTION
24 MB_ICONEXCLAMATION
25 MB_ICONASTERISK
26 MB_ICONWARNING
27 MB_ICONERROR
28 MB_ICONINFORMATION
29 MB_ICONSTOP
30 );
31 @EXPORT_OK = qw(
32 GetOSName
33 SW_HIDE
34 SW_SHOWNORMAL
35 SW_SHOWMINIMIZED
36 SW_SHOWMAXIMIZED
37 SW_SHOWNOACTIVATE
38
39 CSIDL_DESKTOP
40 CSIDL_PROGRAMS
41 CSIDL_PERSONAL
42 CSIDL_FAVORITES
43 CSIDL_STARTUP
44 CSIDL_RECENT
45 CSIDL_SENDTO
46 CSIDL_STARTMENU
47 CSIDL_MYMUSIC
48 CSIDL_MYVIDEO
49 CSIDL_DESKTOPDIRECTORY
50 CSIDL_NETHOOD
51 CSIDL_FONTS
52 CSIDL_TEMPLATES
53 CSIDL_COMMON_STARTMENU
54 CSIDL_COMMON_PROGRAMS
55 CSIDL_COMMON_STARTUP
56 CSIDL_COMMON_DESKTOPDIRECTORY
57 CSIDL_APPDATA
58 CSIDL_PRINTHOOD
59 CSIDL_LOCAL_APPDATA
60 CSIDL_COMMON_FAVORITES
61 CSIDL_INTERNET_CACHE
62 CSIDL_COOKIES
63 CSIDL_HISTORY
64 CSIDL_COMMON_APPDATA
65 CSIDL_WINDOWS
66 CSIDL_SYSTEM
67 CSIDL_PROGRAM_FILES
68 CSIDL_MYPICTURES
69 CSIDL_PROFILE
70 CSIDL_PROGRAM_FILES_COMMON
71 CSIDL_COMMON_TEMPLATES
72 CSIDL_COMMON_DOCUMENTS
73 CSIDL_COMMON_ADMINTOOLS
74 CSIDL_ADMINTOOLS
75 CSIDL_COMMON_MUSIC
76 CSIDL_COMMON_PICTURES
77 CSIDL_COMMON_VIDEO
78 CSIDL_RESOURCES
79 CSIDL_RESOURCES_LOCALIZED
80 CSIDL_CDBURN_AREA
81 );
82}
83
b4ad57f4
NC
84# We won't bother with the constant stuff, too much of a hassle. Just hard
85# code it here.
86
87sub NULL { 0 }
88sub WIN31_CLASS { &NULL }
89
90sub OWNER_SECURITY_INFORMATION { 0x00000001 }
91sub GROUP_SECURITY_INFORMATION { 0x00000002 }
92sub DACL_SECURITY_INFORMATION { 0x00000004 }
93sub SACL_SECURITY_INFORMATION { 0x00000008 }
94
95sub MB_ICONHAND { 0x00000010 }
96sub MB_ICONQUESTION { 0x00000020 }
97sub MB_ICONEXCLAMATION { 0x00000030 }
98sub MB_ICONASTERISK { 0x00000040 }
99sub MB_ICONWARNING { 0x00000030 }
100sub MB_ICONERROR { 0x00000010 }
101sub MB_ICONINFORMATION { 0x00000040 }
102sub MB_ICONSTOP { 0x00000010 }
103
104#
105# Newly added constants. These have an empty prototype, unlike the
106# the ones above, which aren't prototyped for compatibility reasons.
107#
108sub SW_HIDE () { 0 }
109sub SW_SHOWNORMAL () { 1 }
110sub SW_SHOWMINIMIZED () { 2 }
111sub SW_SHOWMAXIMIZED () { 3 }
112sub SW_SHOWNOACTIVATE () { 4 }
113
114sub CSIDL_DESKTOP () { 0x0000 } # <desktop>
115sub CSIDL_PROGRAMS () { 0x0002 } # Start Menu\Programs
116sub CSIDL_PERSONAL () { 0x0005 } # "My Documents" folder
117sub CSIDL_FAVORITES () { 0x0006 } # <user name>\Favorites
118sub CSIDL_STARTUP () { 0x0007 } # Start Menu\Programs\Startup
119sub CSIDL_RECENT () { 0x0008 } # <user name>\Recent
120sub CSIDL_SENDTO () { 0x0009 } # <user name>\SendTo
121sub CSIDL_STARTMENU () { 0x000B } # <user name>\Start Menu
122sub CSIDL_MYMUSIC () { 0x000D } # "My Music" folder
123sub CSIDL_MYVIDEO () { 0x000E } # "My Videos" folder
124sub CSIDL_DESKTOPDIRECTORY () { 0x0010 } # <user name>\Desktop
125sub CSIDL_NETHOOD () { 0x0013 } # <user name>\nethood
126sub CSIDL_FONTS () { 0x0014 } # windows\fonts
127sub CSIDL_TEMPLATES () { 0x0015 }
128sub CSIDL_COMMON_STARTMENU () { 0x0016 } # All Users\Start Menu
129sub CSIDL_COMMON_PROGRAMS () { 0x0017 } # All Users\Start Menu\Programs
130sub CSIDL_COMMON_STARTUP () { 0x0018 } # All Users\Startup
131sub CSIDL_COMMON_DESKTOPDIRECTORY () { 0x0019 } # All Users\Desktop
132sub CSIDL_APPDATA () { 0x001A } # Application Data, new for NT4
133sub CSIDL_PRINTHOOD () { 0x001B } # <user name>\PrintHood
134sub CSIDL_LOCAL_APPDATA () { 0x001C } # non roaming, user\Local Settings\Application Data
135sub CSIDL_COMMON_FAVORITES () { 0x001F }
136sub CSIDL_INTERNET_CACHE () { 0x0020 }
137sub CSIDL_COOKIES () { 0x0021 }
138sub CSIDL_HISTORY () { 0x0022 }
139sub CSIDL_COMMON_APPDATA () { 0x0023 } # All Users\Application Data
140sub CSIDL_WINDOWS () { 0x0024 } # GetWindowsDirectory()
141sub CSIDL_SYSTEM () { 0x0025 } # GetSystemDirectory()
142sub CSIDL_PROGRAM_FILES () { 0x0026 } # C:\Program Files
143sub CSIDL_MYPICTURES () { 0x0027 } # "My Pictures", new for Win2K
144sub CSIDL_PROFILE () { 0x0028 } # USERPROFILE
145sub CSIDL_PROGRAM_FILES_COMMON () { 0x002B } # C:\Program Files\Common
146sub CSIDL_COMMON_TEMPLATES () { 0x002D } # All Users\Templates
147sub CSIDL_COMMON_DOCUMENTS () { 0x002E } # All Users\Documents
148sub CSIDL_COMMON_ADMINTOOLS () { 0x002F } # All Users\Start Menu\Programs\Administrative Tools
149sub CSIDL_ADMINTOOLS () { 0x0030 } # <user name>\Start Menu\Programs\Administrative Tools
150sub CSIDL_COMMON_MUSIC () { 0x0035 } # All Users\My Music
151sub CSIDL_COMMON_PICTURES () { 0x0036 } # All Users\My Pictures
152sub CSIDL_COMMON_VIDEO () { 0x0037 } # All Users\My Video
153sub CSIDL_RESOURCES () { 0x0038 } # %windir%\Resources\, For theme and other windows resources.
154sub CSIDL_RESOURCES_LOCALIZED () { 0x0039 } # %windir%\Resources\<LangID>, for theme and other windows specific resources.
155sub CSIDL_CDBURN_AREA () { 0x003B } # <user name>\Local Settings\Application Data\Microsoft\CD Burning
156
157### This method is just a simple interface into GetOSVersion(). More
158### specific or demanding situations should use that instead.
159
160my ($found_os, $found_desc);
161
162sub GetOSName {
163 my ($os,$desc,$major, $minor, $build, $id)=("","");
164 unless (defined $found_os) {
165 # If we have a run this already, we have the results cached
166 # If so, return them
167
168 # Use the standard API call to determine the version
169 ($desc, $major, $minor, $build, $id) = Win32::GetOSVersion();
170
171 # If id==0 then its a win32s box -- Meaning Win3.11
172 unless($id) {
173 $os = 'Win32s';
174 }
175 else {
176 # Magic numbers from MSDN documentation of OSVERSIONINFO
177 # Most version names can be parsed from just the id and minor
178 # version
179 $os = {
180 1 => {
181 0 => "95",
182 10 => "98",
183 90 => "Me"
184 },
185 2 => {
b76aa5af 186 0 => "NT4",
b4ad57f4 187 1 => "XP/.Net",
b76aa5af 188 2 => "2003",
b4ad57f4
NC
189 51 => "NT3.51"
190 }
191 }->{$id}->{$minor};
192 }
193
194 # This _really_ shouldnt happen. At least not for quite a while
195 # Politely warn and return undef
196 unless (defined $os) {
197 warn qq[Windows version [$id:$major:$minor] unknown!];
198 return undef;
199 }
200
201 my $tag = "";
202
b76aa5af
JD
203 # But distinguising W2k and Vista from NT4 requires looking at the major version
204 if ($os eq "NT4") {
205 $os = {5 => "2000", 6 => "Vista"}->{$major} || "NT4";
b4ad57f4
NC
206 }
207
208 # For the rest we take a look at the build numbers and try to deduce
209 # the exact release name, but we put that in the $desc
210 elsif ($os eq "95") {
211 if ($build eq '67109814') {
212 $tag = '(a)';
213 }
214 elsif ($build eq '67306684') {
215 $tag = '(b1)';
216 }
217 elsif ($build eq '67109975') {
218 $tag = '(b2)';
219 }
220 }
221 elsif ($os eq "98" && $build eq '67766446') {
222 $tag = '(2nd ed)';
223 }
224
225 if (length $tag) {
226 if (length $desc) {
227 $desc = "$tag $desc";
228 }
229 else {
230 $desc = $tag;
231 }
232 }
233
234 # cache the results, so we dont have to do this again
235 $found_os = "Win$os";
236 $found_desc = $desc;
237 }
238
239 return wantarray ? ($found_os, $found_desc) : $found_os;
240}
241
34f7f30d
SH
242# "no warnings 'redefine';" doesn't work for 5.8.7 and earlier
243local $^W = 0;
b4ad57f4
NC
244bootstrap Win32;
245
2461;
247
248__END__
249
1674ad2b
JD
250=head1 NAME
251
252Win32 - Interfaces to some Win32 API Functions
253
254=head1 DESCRIPTION
255
82adc83d 256The Win32 module contains functions to access Win32 APIs.
1674ad2b
JD
257
258=head2 Alphabetical Listing of Win32 Functions
259
82adc83d
YST
260It is recommended to C<use Win32;> before any of these functions;
261however, for backwards compatibility, those marked as [CORE] will
262automatically do this for you.
263
34f7f30d
SH
264In the function descriptions below the term I<Unicode string> is used
265to indicate that the string may contain characters outside the system
266codepage. The caveat I<If supported by the core Perl version>
267generally means Perl 5.8.9 and later, though some Unicode pathname
268functionality may work on earlier versions.
269
1674ad2b
JD
270=over
271
272=item Win32::AbortSystemShutdown(MACHINE)
273
82adc83d 274Aborts a system shutdown (started by the
1674ad2b
JD
275InitiateSystemShutdown function) on the specified MACHINE.
276
277=item Win32::BuildNumber()
278
b4ad57f4 279[CORE] Returns the ActivePerl build number. This function is
1674ad2b
JD
280only available in the ActivePerl binary distribution.
281
282=item Win32::CopyFile(FROM, TO, OVERWRITE)
283
625a29bd 284[CORE] The Win32::CopyFile() function copies an existing file to a new
b4ad57f4
NC
285file. All file information like creation time and file attributes will
286be copied to the new file. However it will B<not> copy the security
287information. If the destination file already exists it will only be
288overwritten when the OVERWRITE parameter is true. But even this will
625a29bd
GS
289not overwrite a read-only file; you have to unlink() it first
290yourself.
1674ad2b 291
34f7f30d
SH
292=item Win32::CreateDirectory(DIRECTORY)
293
294Creates the DIRECTORY and returns a true value on success. Check $^E
295on failure for extended error information.
296
297DIRECTORY may contain Unicode characters outside the system codepage.
298Once the directory has been created you can use
299Win32::GetANSIPathName() to get a name that can be passed to system
300calls and external programs.
301
302=item Win32::CreateFile(FILE)
303
304Creates the FILE and returns a true value on success. Check $^E on
305failure for extended error information.
306
307FILE may contain Unicode characters outside the system codepage. Once
308the file has been created you can use Win32::GetANSIPathName() to get
309a name that can be passed to system calls and external programs.
310
1674ad2b
JD
311=item Win32::DomainName()
312
313[CORE] Returns the name of the Microsoft Network domain that the
da147683
JD
314owner of the current perl process is logged into. This function does
315B<not> work on Windows 9x.
1674ad2b
JD
316
317=item Win32::ExpandEnvironmentStrings(STRING)
318
82adc83d 319Takes STRING and replaces all referenced environment variable
b4ad57f4
NC
320names with their defined values. References to environment variables
321take the form C<%VariableName%>. Case is ignored when looking up the
322VariableName in the environment. If the variable is not found then the
1674ad2b
JD
323original C<%VariableName%> text is retained. Has the same effect
324as the following:
325
326 $string =~ s/%([^%]*)%/$ENV{$1} || "%$1%"/eg
327
34f7f30d
SH
328However, this function may return a Unicode string if the environment
329variable being expanded hasn't been assigned to via %ENV. Access
330to %ENV is currently always using byte semantics.
331
1674ad2b
JD
332=item Win32::FormatMessage(ERRORCODE)
333
334[CORE] Converts the supplied Win32 error number (e.g. returned by
335Win32::GetLastError()) to a descriptive string. Analogous to the
336perror() standard-C library function. Note that C<$^E> used
337in a string context has much the same effect.
338
339 C:\> perl -e "$^E = 26; print $^E;"
340 The specified disk or diskette cannot be accessed
341
342=item Win32::FsType()
343
344[CORE] Returns the name of the filesystem of the currently active
b4ad57f4
NC
345drive (like 'FAT' or 'NTFS'). In list context it returns three values:
346(FSTYPE, FLAGS, MAXCOMPLEN). FSTYPE is the filesystem type as
347before. FLAGS is a combination of values of the following table:
1674ad2b
JD
348
349 0x00000001 supports case-sensitive filenames
350 0x00000002 preserves the case of filenames
351 0x00000004 supports Unicode in filenames
352 0x00000008 preserves and enforces ACLs
353 0x00000010 supports file-based compression
354 0x00000020 supports disk quotas
355 0x00000040 supports sparse files
356 0x00000080 supports reparse points
357 0x00000100 supports remote storage
358 0x00008000 is a compressed volume (e.g. DoubleSpace)
359 0x00010000 supports object identifiers
360 0x00020000 supports the Encrypted File System (EFS)
361
362MAXCOMPLEN is the maximum length of a filename component (the part
363between two backslashes) on this file system.
364
365=item Win32::FreeLibrary(HANDLE)
366
82adc83d 367Unloads a previously loaded dynamic-link library. The HANDLE is
b4ad57f4 368no longer valid after this call. See L<LoadLibrary|Win32::LoadLibrary(LIBNAME)>
4a4eefd0 369for information on dynamically loading a library.
1674ad2b 370
34f7f30d
SH
371=item Win32::GetANSIPathName(FILENAME)
372
373Returns an ANSI version of FILENAME. This may be the short name
374if the long name cannot be represented in the system codepage.
375
376While not currently implemented, it is possible that in the future
377this function will convert only parts of the path to FILENAME to a
378short form.
379
380If FILENAME doesn't exist on the filesystem, or if the filesystem
381doesn't support short ANSI filenames, then this function will
382translate the Unicode name into the system codepage using replacement
383characters.
384
1674ad2b
JD
385=item Win32::GetArchName()
386
82adc83d 387Use of this function is deprecated. It is equivalent with
b4ad57f4 388$ENV{PROCESSOR_ARCHITECTURE}. This might not work on Win9X.
1674ad2b
JD
389
390=item Win32::GetChipName()
391
82adc83d 392Returns the processor type: 386, 486 or 586 for Intel processors,
1674ad2b
JD
39321064 for the Alpha chip.
394
395=item Win32::GetCwd()
396
b4ad57f4 397[CORE] Returns the current active drive and directory. This function
1674ad2b
JD
398does not return a UNC path, since the functionality required for such
399a feature is not available under Windows 95.
400
34f7f30d
SH
401If supported by the core Perl version, this function will return an
402ANSI path name for the current directory if the long pathname cannot
403be represented in the system codepage.
404
405=item Win32::GetCurrentThreadId()
406
407Returns the thread identifier of the calling thread. Until the thread
408terminates, the thread identifier uniquely identifies the thread
409throughout the system.
410
411Note: the current process identifier is available via the predefined
412$$ variable.
413
e364e11c
JD
414=item Win32::GetFileVersion(FILENAME)
415
82adc83d 416Returns the file version number from the VERSIONINFO resource of
e364e11c
JD
417the executable file or DLL. This is a tuple of four 16 bit numbers.
418In list context these four numbers will be returned. In scalar context
419they are concatenated into a string, separated by dots.
420
87755fa7
GS
421=item Win32::GetFolderPath(FOLDER [, CREATE])
422
82adc83d 423Returns the full pathname of one of the Windows special folders.
87755fa7
GS
424The folder will be created if it doesn't exist and the optional CREATE
425argument is true. The following FOLDER constants are defined by the
426Win32 module, but only exported on demand:
427
428 CSIDL_ADMINTOOLS
429 CSIDL_APPDATA
430 CSIDL_CDBURN_AREA
431 CSIDL_COMMON_ADMINTOOLS
432 CSIDL_COMMON_APPDATA
433 CSIDL_COMMON_DESKTOPDIRECTORY
434 CSIDL_COMMON_DOCUMENTS
435 CSIDL_COMMON_FAVORITES
436 CSIDL_COMMON_MUSIC
437 CSIDL_COMMON_PICTURES
438 CSIDL_COMMON_PROGRAMS
439 CSIDL_COMMON_STARTMENU
440 CSIDL_COMMON_STARTUP
441 CSIDL_COMMON_TEMPLATES
442 CSIDL_COMMON_VIDEO
443 CSIDL_COOKIES
444 CSIDL_DESKTOP
445 CSIDL_DESKTOPDIRECTORY
446 CSIDL_FAVORITES
447 CSIDL_FONTS
448 CSIDL_HISTORY
449 CSIDL_INTERNET_CACHE
450 CSIDL_LOCAL_APPDATA
451 CSIDL_MYMUSIC
452 CSIDL_MYPICTURES
453 CSIDL_MYVIDEO
454 CSIDL_NETHOOD
455 CSIDL_PERSONAL
456 CSIDL_PRINTHOOD
457 CSIDL_PROFILE
458 CSIDL_PROGRAMS
459 CSIDL_PROGRAM_FILES
460 CSIDL_PROGRAM_FILES_COMMON
461 CSIDL_RECENT
462 CSIDL_RESOURCES
463 CSIDL_RESOURCES_LOCALIZED
464 CSIDL_SENDTO
465 CSIDL_STARTMENU
466 CSIDL_STARTUP
467 CSIDL_SYSTEM
468 CSIDL_TEMPLATES
469 CSIDL_WINDOWS
470
471Note that not all folders are defined on all versions of Windows.
472
473Please refer to the MSDN documentation of the CSIDL constants,
474currently available at:
475
476http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp
477
34f7f30d
SH
478This function will return an ANSI folder path if the long name cannot
479be represented in the system codepage. Use Win32::GetLongPathName()
480on the result of Win32::GetFolderPath() if you want the Unicode
481version of the folder name.
482
1674ad2b
JD
483=item Win32::GetFullPathName(FILENAME)
484
485[CORE] GetFullPathName combines the FILENAME with the current drive
486and directory name and returns a fully qualified (aka, absolute)
b4ad57f4 487path name. In list context it returns two elements: (PATH, FILE) where
1674ad2b
JD
488PATH is the complete pathname component (including trailing backslash)
489and FILE is just the filename part. Note that no attempt is made to
490convert 8.3 components in the supplied FILENAME to longnames or
34f7f30d
SH
491vice-versa. Compare with Win32::GetShortPathName() and
492Win32::GetLongPathName().
493
494If supported by the core Perl version, this function will return an
495ANSI path name if the full pathname cannot be represented in the
496system codepage.
1674ad2b
JD
497
498=item Win32::GetLastError()
499
500[CORE] Returns the last error value generated by a call to a Win32 API
501function. Note that C<$^E> used in a numeric context amounts to the
502same value.
503
504=item Win32::GetLongPathName(PATHNAME)
505
4375e838 506[CORE] Returns a representation of PATHNAME composed of longname
da2094fd 507components (if any). The result may not necessarily be longer
1674ad2b 508than PATHNAME. No attempt is made to convert PATHNAME to the
34f7f30d
SH
509absolute path. Compare with Win32::GetShortPathName() and
510Win32::GetFullPathName().
511
512This function may return the pathname in Unicode if it cannot be
513represented in the system codepage. Use Win32::GetANSIPathName()
514before passing the path to a system call or another program.
1674ad2b 515
1674ad2b
JD
516=item Win32::GetNextAvailDrive()
517
518[CORE] Returns a string in the form of "<d>:" where <d> is the first
519available drive letter.
520
521=item Win32::GetOSVersion()
522
3e526985 523[CORE] Returns the list (STRING, MAJOR, MINOR, BUILD, ID), where the
d10f8d7a
YO
524elements are, respectively: An arbitrary descriptive string, the major
525version number of the operating system, the minor version number, the
526build number, and a digit indicating the actual operating system.
3e526985
JD
527For the ID, the values are 0 for Win32s, 1 for Windows 9X/Me and 2 for
528Windows NT/2000/XP/2003. In scalar context it returns just the ID.
d10f8d7a
YO
529
530Currently known values for ID MAJOR and MINOR are as follows:
531
532 OS ID MAJOR MINOR
533 Win32s 0 - -
534 Windows 95 1 4 0
535 Windows 98 1 4 10
536 Windows Me 1 4 90
537 Windows NT 3.51 2 3 51
538 Windows NT 4 2 4 0
539 Windows 2000 2 5 0
540 Windows XP 2 5 1
3e526985 541 Windows Server 2003 2 5 2
b76aa5af 542 Windows Vista 2 6 0
3e526985
JD
543
544On Windows NT 4 SP6 and later this function returns the following
545additional values: SPMAJOR, SPMINOR, SUITEMASK, PRODUCTTYPE.
546
547SPMAJOR and SPMINOR are are the version numbers of the latest
548installed service pack.
549
550SUITEMASK is a bitfield identifying the product suites available on
551the system. Known bits are:
552
553 VER_SUITE_SMALLBUSINESS 0x00000001
554 VER_SUITE_ENTERPRISE 0x00000002
555 VER_SUITE_BACKOFFICE 0x00000004
556 VER_SUITE_COMMUNICATIONS 0x00000008
557 VER_SUITE_TERMINAL 0x00000010
558 VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
559 VER_SUITE_EMBEDDEDNT 0x00000040
560 VER_SUITE_DATACENTER 0x00000080
561 VER_SUITE_SINGLEUSERTS 0x00000100
562 VER_SUITE_PERSONAL 0x00000200
563 VER_SUITE_BLADE 0x00000400
564 VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
565 VER_SUITE_SECURITY_APPLIANCE 0x00001000
566
567The VER_SUITE_xxx names are listed here to crossreference the Microsoft
568documentation. The Win32 module does not provide symbolic names for these
569constants.
570
571PRODUCTTYPE provides additional information about the system. It should
572be one of the following integer values:
573
574 1 - Workstation (NT 4, 2000 Pro, XP Home, XP Pro)
575 2 - Domaincontroller
576 3 - Server
d10f8d7a
YO
577
578=item Win32::GetOSName()
579
82adc83d 580In scalar context returns the name of the Win32 operating system
d10f8d7a
YO
581being used. In list context returns a two element list of the OS name
582and whatever edition information is known about the particular build
b4ad57f4 583(for Win9X boxes) and whatever service packs have been installed.
d10f8d7a
YO
584The latter is roughly equivalent to the first item returned by
585GetOSVersion() in list context.
586
587Currently the possible values for the OS name are
588
3e526985 589 Win32s Win95 Win98 WinMe WinNT3.51 WinNT4 Win2000 WinXP/.Net Win2003
d10f8d7a
YO
590
591This routine is just a simple interface into GetOSVersion(). More
592specific or demanding situations should use that instead. Another
593option would be to use POSIX::uname(), however the latter appears to
594report only the OS family name and not the specific OS. In scalar
595context it returns just the ID.
1674ad2b 596
3e526985
JD
597The name "WinXP/.Net" is used for historical reasons only, to maintain
598backwards compatibility of the Win32 module. Windows .NET Server has
599been renamed as Windows 2003 Server before final release and uses a
600different major/minor version number than Windows XP.
601
1674ad2b
JD
602=item Win32::GetShortPathName(PATHNAME)
603
eb6bfc3a
GA
604[CORE] Returns a representation of PATHNAME that is composed of short
605(8.3) path components where available. For path components where the
606file system has not generated the short form the returned path will
607use the long form, so this function might still for instance return a
b3eb56ab
SH
608path containing spaces. Returns C<undef> when the PATHNAME does not
609exist. Compare with Win32::GetFullPathName() and
34f7f30d 610Win32::GetLongPathName().
1674ad2b
JD
611
612=item Win32::GetProcAddress(INSTANCE, PROCNAME)
613
82adc83d 614Returns the address of a function inside a loaded library. The
1674ad2b 615information about what you can do with this address has been lost in
b4ad57f4 616the mist of time. Use the Win32::API module instead of this deprecated
1674ad2b
JD
617function.
618
619=item Win32::GetTickCount()
620
621[CORE] Returns the number of milliseconds elapsed since the last
b4ad57f4 622system boot. Resolution is limited to system timer ticks (about 10ms
1674ad2b
JD
623on WinNT and 55ms on Win9X).
624
e364e11c
JD
625=item Win32::GuidGen()
626
82adc83d 627Creates a globally unique 128 bit integer that can be used as a
e364e11c
JD
628persistent identifier in a distributed setting. To a very high degree
629of certainty this function returns a unique value. No other
630invocation, on the same or any other system (networked or not), should
631return the same value.
632
633The return value is formatted according to OLE conventions, as groups
634of hex digits with surrounding braces. For example:
635
636 {09531CF1-D0C7-4860-840C-1C8C8735E2AD}
637
cb49b31f 638=item Win32::InitiateSystemShutdown
551e1d92 639
cb49b31f 640(MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)
1674ad2b 641
82adc83d 642Shutsdown the specified MACHINE, notifying users with the
b4ad57f4 643supplied MESSAGE, within the specified TIMEOUT interval. Forces
1674ad2b 644closing of all documents without prompting the user if FORCECLOSE is
b4ad57f4 645true, and reboots the machine if REBOOT is true. This function works
1674ad2b
JD
646only on WinNT.
647
b4ad57f4
NC
648=item Win32::IsAdminUser()
649
82adc83d 650Returns non zero if the account in whose security context the
b4ad57f4
NC
651current process/thread is running belongs to the local group of
652Administrators in the built-in system domain; returns 0 if not.
34f7f30d 653On Windows Vista it will only return non-zero if the process is
b3eb56ab
SH
654actually running with elevated privileges. Returns C<undef>
655and prints a warning if an error occurred. This function always
34f7f30d 656returns 1 on Win9X.
b4ad57f4 657
1674ad2b
JD
658=item Win32::IsWinNT()
659
660[CORE] Returns non zero if the Win32 subsystem is Windows NT.
661
662=item Win32::IsWin95()
663
664[CORE] Returns non zero if the Win32 subsystem is Windows 95.
665
666=item Win32::LoadLibrary(LIBNAME)
667
82adc83d 668Loads a dynamic link library into memory and returns its module
34f7f30d
SH
669handle. This handle can be used with Win32::GetProcAddress() and
670Win32::FreeLibrary(). This function is deprecated. Use the Win32::API
1674ad2b
JD
671module instead.
672
673=item Win32::LoginName()
674
675[CORE] Returns the username of the owner of the current perl process.
34f7f30d 676The return value may be a Unicode string.
1674ad2b
JD
677
678=item Win32::LookupAccountName(SYSTEM, ACCOUNT, DOMAIN, SID, SIDTYPE)
679
82adc83d 680Looks up ACCOUNT on SYSTEM and returns the domain name the SID and
1674ad2b
JD
681the SID type.
682
683=item Win32::LookupAccountSID(SYSTEM, SID, ACCOUNT, DOMAIN, SIDTYPE)
684
82adc83d 685Looks up SID on SYSTEM and returns the account name, domain name,
1674ad2b
JD
686and the SID type.
687
688=item Win32::MsgBox(MESSAGE [, FLAGS [, TITLE]])
689
82adc83d 690Create a dialogbox containing MESSAGE. FLAGS specifies the
1674ad2b
JD
691required icon and buttons according to the following table:
692
693 0 = OK
694 1 = OK and Cancel
695 2 = Abort, Retry, and Ignore
696 3 = Yes, No and Cancel
697 4 = Yes and No
698 5 = Retry and Cancel
699
700 MB_ICONSTOP "X" in a red circle
701 MB_ICONQUESTION question mark in a bubble
702 MB_ICONEXCLAMATION exclamation mark in a yellow triangle
703 MB_ICONINFORMATION "i" in a bubble
704
b4ad57f4 705TITLE specifies an optional window title. The default is "Perl".
1674ad2b
JD
706
707The function returns the menu id of the selected push button:
708
709 0 Error
710
711 1 OK
712 2 Cancel
713 3 Abort
714 4 Retry
715 5 Ignore
716 6 Yes
717 7 No
718
719=item Win32::NodeName()
720
721[CORE] Returns the Microsoft Network node-name of the current machine.
722
34f7f30d
SH
723=item Win32::OutputDebugString(STRING)
724
725Sends a string to the application or system debugger for display.
726The function does nothing if there is no active debugger.
727
728Alternatively one can use the I<Debug Viewer> application to
729watch the OutputDebugString() output:
730
731http://www.microsoft.com/technet/sysinternals/utilities/debugview.mspx
732
1674ad2b
JD
733=item Win32::RegisterServer(LIBRARYNAME)
734
82adc83d 735Loads the DLL LIBRARYNAME and calls the function DllRegisterServer.
1674ad2b 736
02637f4c
JD
737=item Win32::SetChildShowWindow(SHOWWINDOW)
738
739[CORE] Sets the I<ShowMode> of child processes started by system().
740By default system() will create a new console window for child
b4ad57f4 741processes if Perl itself is not running from a console. Calling
02637f4c
JD
742SetChildShowWindow(0) will make these new console windows invisible.
743Calling SetChildShowWindow() without arguments reverts system() to the
744default behavior. The return value of SetChildShowWindow() is the
34f7f30d 745previous setting or C<undef>.
02637f4c 746
82adc83d 747The following symbolic constants for SHOWWINDOW are available
02637f4c
JD
748(but not exported) from the Win32 module: SW_HIDE, SW_SHOWNORMAL,
749SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED and SW_SHOWNOACTIVATE.
750
1674ad2b
JD
751=item Win32::SetCwd(NEWDIRECTORY)
752
b4ad57f4 753[CORE] Sets the current active drive and directory. This function does not
1674ad2b
JD
754work with UNC paths, since the functionality required to required for
755such a feature is not available under Windows 95.
756
757=item Win32::SetLastError(ERROR)
758
b4ad57f4 759[CORE] Sets the value of the last error encountered to ERROR. This is
1674ad2b 760that value that will be returned by the Win32::GetLastError()
b4ad57f4 761function.
1674ad2b
JD
762
763=item Win32::Sleep(TIME)
764
b4ad57f4 765[CORE] Pauses for TIME milliseconds. The timeslices are made available
1674ad2b
JD
766to other processes and threads.
767
768=item Win32::Spawn(COMMAND, ARGS, PID)
769
770[CORE] Spawns a new process using the supplied COMMAND, passing in
b4ad57f4
NC
771arguments in the string ARGS. The pid of the new process is stored in
772PID. This function is deprecated. Please use the Win32::Process module
1674ad2b
JD
773instead.
774
775=item Win32::UnregisterServer(LIBRARYNAME)
776
82adc83d 777Loads the DLL LIBRARYNAME and calls the function
1674ad2b
JD
778DllUnregisterServer.
779
780=back
781
782=cut