Thread Dateigröße ermitteln: während des Kopiervorgangs (15 answers)
Opened by jane_templar at 2004-02-09 08:06

esskar
 2004-02-17 01:12
#79970 #79970
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
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
use strict;

use constant GENERIC_READ => 0x80000000;
use constant OPEN_EXISTING => 3;
use constant FILE_ATTRIBUTE_NORMAL => 0x00000080;


use Win32::API;
use Win32::API::Struct;

Win32::API::Struct->typedef(SECURITY_ATTRIBUTES => qw{
DWORD nLength
LPVOID lpSecurityDescriptor
BOOL bInheritHandle
});


Win32::API->Import('kernel32', 'HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)');
Win32::API->Import('kernel32', 'DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)');
Win32::API->Import('kernel32', 'BOOL CloseHandle(HANDLE hObject)');

sub GetOpenFileSizeWin
{
my ($file) = @_;
my $handle = 0;
my $size = 0;

$handle = CreateFile($file, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if($handle)
{
$size = GetFileSize($handle, 0);
CloseHandle($handle);
}
return $size;
}


so kompiliert das script zwar, aber es kommt ein "Dr. Watson" wenn ich die Funktion auf ein File anwende...
muss man wohl noch mal genau debuggen!

View full thread Dateigröße ermitteln: während des Kopiervorgangs