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