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