-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathkernel32.html
793 lines (473 loc) · 12.4 KB
/
kernel32.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<HTML>
<HEAD>
<TITLE>Win32::kernel32 - Experimental interface to some of the KERNEL32.DLL functions
</TITLE>
</HEAD>
<BODY>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#NAME">NAME</A>
<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
<LI><A HREF="#FUNCTIONS">FUNCTIONS</A>
<UL>
<LI><A HREF="#Beep">Beep</A>
<LI><A HREF="#CopyFile">CopyFile</A>
<LI><A HREF="#GetBinaryType">GetBinaryType</A>
<LI><A HREF="#GetCompressedFileSize">GetCompressedFileSize</A>
<LI><A HREF="#GetCommandLine">GetCommandLine</A>
<LI><A HREF="#GetCurrencyFormat">GetCurrencyFormat</A>
<LI><A HREF="#GetDiskFreeSpace">GetDiskFreeSpace</A>
<LI><A HREF="#GetDriveType">GetDriveType</A>
<LI><A HREF="#GetTempPath">GetTempPath</A>
<LI><A HREF="#GetVolumeInformation">GetVolumeInformation</A>
<LI><A HREF="#MultiByteToWideChar">MultiByteToWideChar</A>
<LI><A HREF="#QueryPerformanceCounter">QueryPerformanceCounter</A>
<LI><A HREF="#QueryPerformanceFrequency">QueryPerformanceFrequency</A>
<LI><A HREF="#SearchPath">SearchPath</A>
<LI><A HREF="#SetLastError">SetLastError</A>
<LI><A HREF="#Sleep">Sleep</A>
<LI><A HREF="#VerLanguageName">VerLanguageName</A>
<LI><A HREF="#WideCharToMultiByte">WideCharToMultiByte</A>
<LI><A HREF="#Yet_to_be_documented">Yet to be documented</A>
</UL>
<LI><A HREF="#AUTHOR">AUTHOR</A>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="NAME">NAME
</A></H1>
Win32::kernel32 - Experimental interface to some of the KERNEL32.DLL
functions
<P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS
</A></H1>
<PRE> use Win32::kernel32;
</PRE>
<P>
<PRE> # or
</PRE>
<P>
<PRE> use Win32::kernel32 qw( Sleep CopyFile GetVolumeInformation );
</PRE>
<P>
<P>
<HR>
<H1><A NAME="FUNCTIONS">FUNCTIONS
</A></H1>
<P>
<HR>
<H4><A NAME="Beep">Beep
</A></H4>
Syntax:
<P>
<PRE> Win32::Beep ( [FREQUENCY, DURATION] )
</PRE>
<P>
Plays a simple tone on the speaker; <CODE>FREQUENCY</CODE> is expressed in hertz and ranges from 37 to 32767, <CODE>DURATION</CODE> is expressed in milliseconds. Note that parameters are relevant only on
Windows NT; on Windows 95, parameters are ignored and the system plays the
default sound event (or a standard system beep on the speaker if you have
no sound card).
<P>
Example:
<P>
<PRE> Win32::Beep(440, 1000);
</PRE>
<P>
<P>
<HR>
<H4><A NAME="CopyFile">CopyFile
</A></H4>
Syntax:
<P>
<PRE> Win32::CopyFile ( SOURCE, TARGET, [SAFE] )
</PRE>
<P>
Copies the <CODE>SOURCE</CODE> file to <CODE>TARGET</CODE>. By default, it fails if <CODE>TARGET</CODE> already exists; to overwrite the already existing file, the <CODE>SAFE</CODE> flag must be set to 0. Returns a true value if the operation was
successfull, a false one if it failed.
<P>
Example:
<P>
<PRE> if(Win32::CopyFile($from, $to)) {
print "Copy OK.\n";
} else {
# overwrite the already existing file
if(Win32::CopyFile($from, $to, 0)) {
print "Copy OK, file replaced.\n";
} else {
print "Copy failed.\n";
}
}
</PRE>
<P>
<P>
<HR>
<H4><A NAME="GetBinaryType">GetBinaryType
</A></H4>
Syntax:
<P>
<PRE> Win32::GetBinaryType ( FILENAME )
</PRE>
<P>
Returns the type ot the executable file <CODE>FILENAME</CODE>. Possible values are:
<P>
<PRE> 0 A Win32 based application
1 An MS-DOS based application
2 A 16-bit Windows based application
3 A PIF file that executes an MS-DOS based application
4 A POSIX based application
5 A 16-bit OS/2 based application
</PRE>
<P>
If the function fails, <CODE>undef</CODE> is returned.
<P>
<STRONG>Note</STRONG>: this function is available on Windows NT only.
<P>
Example:
<P>
<PRE> print "Notepad is a type ", Win32::GetBinaryType("c:\\winnt\\notepad.exe"), "\n";
</PRE>
<P>
<P>
<HR>
<H4><A NAME="GetCompressedFileSize">GetCompressedFileSize
</A></H4>
Syntax:
<P>
<PRE> Win32::GetCompressedFileSize ( FILENAME )
</PRE>
<P>
Returns the compressed size of the specified <CODE>FILENAME</CODE>, if the file is compressed; if it's not compressed, it returns the normal
file size (eg. same as <CODE>-s</CODE>).
<P>
<STRONG>Note</STRONG>: this function is available on Windows NT only.
<P>
Example:
<P>
<PRE> print Win32::GetCompressedFileSize("c:\\documents\\longlog.txt");
</PRE>
<P>
<P>
<HR>
<H4><A NAME="GetCommandLine">GetCommandLine
</A></H4>
Syntax:
<P>
<PRE> Win32::GetCommandLine ( )
</PRE>
<P>
Returns the complete command line string, including the full path to the
program name and its arguments.
<P>
Example:
<P>
<PRE> print Win32::GetCommandLine();
</PRE>
<P>
<P>
<HR>
<H4><A NAME="GetCurrencyFormat">GetCurrencyFormat
</A></H4>
Syntax:
<P>
<PRE> Win32::GetCurrencyFormat ( NUMBER, [LOCALE] )
</PRE>
<P>
Returns <CODE>NUMBER</CODE> formatted to your locale's currency settings. You can optionally supply a
different <CODE>LOCALE</CODE> for foreign currencies.
<P>
Example:
<P>
<PRE> print "You owe me ", Win32::GetCurrencyFormat(rand()*10000), "\n";
</PRE>
<P>
<PRE> # ten millions italian lires...
$LotOfMoney = Win32::GetCurrencyFormat(10000000, 1040);
</PRE>
<P>
<PRE> # 1040 is "Italian (Standard)" (see also VerLanguageName)
# and it returns: L. 10.000.000
</PRE>
<P>
<P>
<HR>
<H4><A NAME="GetDiskFreeSpace">GetDiskFreeSpace
</A></H4>
Syntax:
<P>
<PRE> Win32::GetDiskFreeSpace ( [ROOT] )
</PRE>
<P>
Returns the amount of free disk space on the drive indicated by <CODE>ROOT</CODE>; if this is omitted, uses the current drive. To specify a drive, you must
provide the exact root directory (eg. for drive C: it must be: ``C:\''). In
a scalar context, it returns the number of free bytes; in a list context,
it returns the number of free bytes and the total number of bytes on the
disk.
<P>
Example:
<P>
<PRE> $free = Win32::GetDiskFreeSpace("c:\\");
($free, $total) = Win32::GetDiskFreeSpace();
</PRE>
<P>
<P>
<HR>
<H4><A NAME="GetDriveType">GetDriveType
</A></H4>
Syntax:
<P>
<PRE> Win32::GetDriveType ( [ROOT] )
</PRE>
<P>
Returns the type ot the drive indicated by <CODE>ROOT</CODE>. If this is omitted, uses the current drive. To specify a drive, you must
provide the exact root directory (eg. for drive C: it must be: ``C:\'').
Possible return values are:
<P>
<PRE> 0 The drive type cannot be determined
1 The root directory does not exist
2 The disk can be removed from the drive
3 The disk cannot be removed from the drive
4 The drive is a remote (network) drive
5 The drive is a CD-ROM drive
6 The drive is a RAM disk
</PRE>
<P>
Example:
<P>
<PRE> print "C: is a type ", Win32::GetDriveType("c:\\"), "\n";
</PRE>
<P>
<P>
<HR>
<H4><A NAME="GetTempPath">GetTempPath
</A></H4>
Syntax:
<P>
<PRE> Win32::GetTempPath ( )
</PRE>
<P>
Returns the path of the directory designated for temporary files, or <CODE>undef</CODE> on errors.
<P>
Example:
<P>
<PRE> print "Please put your temp files in ", Win32::GetTempPath(), "\n";
</PRE>
<P>
<P>
<HR>
<H4><A NAME="GetVolumeInformation">GetVolumeInformation
</A></H4>
Syntax:
<P>
<PRE> Win32::GetVolumeInformation ( [ROOT] )
</PRE>
<P>
Returns a 5-elements array with some information about the drive indicated
by <CODE>ROOT</CODE>. If this is omitted, uses the current drive. Typically used as follows:
<P>
<PRE> ($label, $serial, $maxlen, $flags, $fstype) = Win32::GetVolumeInformation();
</PRE>
<P>
Here are the meaning of the fields:
<P>
<PRE> label the volume label
serial the volume serial number
maxlen the maximum filename length, in chars, supported by the volume
flags a set of flags associated with the file system
fstype the type of the file system (such as FAT or NTFS)
</PRE>
<P>
For more information about the <CODE>flags</CODE> field, please refer to the <CODE>GetVolumeInformation()</CODE>
documentation in the Microsoft Win32 SDK Reference.
<P>
If called in a scalar context, the function returns only the first element
(the volume label).
<P>
Example:
<P>
<PRE> $volume = Win32::GetVolumeInformation();
print "Working on $volume...";
</PRE>
<P>
<P>
<HR>
<H4><A NAME="MultiByteToWideChar">MultiByteToWideChar
</A></H4>
Syntax:
<P>
<PRE> Win32::MultiByteToWideChar ( STRING, [CODEPAGE] )
</PRE>
<P>
Converts a <CODE>STRING</CODE> in Unicode format. The additional
<CODE>CODEPAGE</CODE> parameter can have one of this values:
<P>
<PRE> 0 ANSI codepage
1 OEM codepage
2 MAC codepage
</PRE>
<P>
Or the number of a codepage installed on your system (eg. 850 for ``MS-DOS
Multilingual (Latin I)''). The default, if none specified, is the ANSI
codepage. Returns the converted string or <CODE>undef</CODE> on errors.
<P>
Example:
<P>
<PRE> $UnicodeString = Win32::MultiByteToWideChar($string);
</PRE>
<P>
<P>
<HR>
<H4><A NAME="QueryPerformanceCounter">QueryPerformanceCounter
</A></H4>
Syntax:
<P>
<PRE> Win32::QueryPerformanceCounter ( )
</PRE>
<P>
Retrieves the current value of the high-resolution performance counter, if
it exists. Returns zero if it doesn't. To see how many times per second the
counter is incremented, use <CODE>QueryPerformanceFrequency</CODE>.
<P>
Example:
<P>
<PRE> $freq = Win32::QueryPerformanceFrequency();
$count1 = Win32::QueryPerformanceCounter();
# do something
$count2 = Win32::QueryPerformanceCounter();
print ($count2-$count1)/$freq , " seconds elapsed.\n";
</PRE>
<P>
<P>
<HR>
<H4><A NAME="QueryPerformanceFrequency">QueryPerformanceFrequency
</A></H4>
Syntax:
<P>
<PRE> Win32::QueryPerformanceFrequency ( )
</PRE>
<P>
Returns the frequency of the high-resolution performance counter, if it
exists. Returns zero if it doesn't. See also <CODE>QueryPerformanceCounter</CODE>.
<P>
<P>
<HR>
<H4><A NAME="SearchPath">SearchPath
</A></H4>
Syntax:
<P>
<PRE> Win32::SearchPath ( FILENAME )
</PRE>
<P>
Search for the specified <CODE>FILENAME</CODE> in the path. The following directories are searched:
<P>
<PRE> 1. the directory from which the application loaded.
2. the current directory
3. the Windows system directory
4. the Windows directory
5. the directories in the PATH environment variable
</PRE>
<P>
Returns the full path to the found file or <CODE>undef</CODE>
if the file was not found.
<P>
Example:
<P>
<PRE> print "Notepad exists" if -f Win32::SearchPath("notepad.exe");
</PRE>
<P>
<P>
<HR>
<H4><A NAME="SetLastError">SetLastError
</A></H4>
Syntax:
<P>
<PRE> Win32::SetLastError ( VALUE )
</PRE>
<P>
Sets the Win32 last error to the specified <CODE>VALUE</CODE>.
<P>
Example:
<P>
<PRE> # reset pending errors
Win32::SetLastError(0);
</PRE>
<P>
<P>
<HR>
<H4><A NAME="Sleep">Sleep
</A></H4>
Syntax:
<P>
<PRE> Win32::Sleep ( MILLISECONDS )
</PRE>
<P>
Sleeps for the number of <CODE>MILLISECONDS</CODE> specified.
<P>
Example:
<P>
<PRE> # sleep for 1/2 second
Win32::Sleep(500);
</PRE>
<P>
<P>
<HR>
<H4><A NAME="VerLanguageName">VerLanguageName
</A></H4>
Syntax:
<P>
<PRE> Win32::VerLanguageName ( LOCALE )
</PRE>
<P>
Returns a descriptive string for the language associated with the specified <CODE>LOCALE</CODE>.
<P>
Example:
<P>
<PRE> $ITA = Win32::VerLanguageName(1040);
$JAP = Win32::VerLanguageName(1041);
</PRE>
<P>
<P>
<HR>
<H4><A NAME="WideCharToMultiByte">WideCharToMultiByte
</A></H4>
Syntax:
<P>
<PRE> Win32::WideCharToMultiByte ( STRING, [CODEPAGE] )
</PRE>
<P>
Converts an Unicode <CODE>STRING</CODE> to a non-Unicode one. The additional
<CODE>CODEPAGE</CODE> parameter can have one of this values:
<P>
<PRE> 0 ANSI codepage
1 OEM codepage
2 MAC codepage
</PRE>
<P>
Or the number of a codepage installed on your system (eg. 850 for ``MS-DOS
Multilingual (Latin I)''). The default, if none specified, is the ANSI
codepage. Returns the converted string or <CODE>undef</CODE> on errors.
<P>
Example:
<P>
<PRE> $string = Win32::WideCharToMultiByte($UnicodeString);
</PRE>
<P>
<P>
<HR>
<H4><A NAME="Yet_to_be_documented">Yet to be documented
</A></H4>
<PRE> GetSystemTime => [[P], V],
QueryDosDevice => [[P, P, N], N],
</PRE>
<P>
<P>
<HR>
<H1><A NAME="AUTHOR">AUTHOR
</A></H1>
Aldo Calpini ( <EM>[email protected]</EM> ).
<P>
</DL>
</BODY>
</HTML>