Subversion Repositories recyclebinunit

Rev

Rev 93 | Rev 96 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 93 Rev 95
Line 378... Line 378...
378
  TGetVolumeNameForVolumeMountPoint = function(lpszVolumeMountPoint: LPCTSTR; lpszVolumeName: LPTSTR; cchBufferLength: DWORD): BOOL; stdcall;
378
  TGetVolumeNameForVolumeMountPoint = function(lpszVolumeMountPoint: LPCTSTR; lpszVolumeName: LPTSTR; cchBufferLength: DWORD): BOOL; stdcall;
379
  TSHEmptyRecycleBin = function(Wnd: HWND; pszRootPath: LPCTSTR; dwFlags: DWORD): HRESULT; stdcall;
379
  TSHEmptyRecycleBin = function(Wnd: HWND; pszRootPath: LPCTSTR; dwFlags: DWORD): HRESULT; stdcall;
380
  TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall;
380
  TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall;
381
  TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall;
381
  TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall;
382
 
382
 
-
 
383
type
-
 
384
  TWideCharArray = array of WideChar;
-
 
385
  TAnsiCharArray = array of AnsiChar;
-
 
386
 
383
function WideCharArrayToWideString(x: array of WideChar): WideString;
387
function WideCharArrayToWideString(x: TWideCharArray): WideString;
384
var
388
var
385
  i: integer;
389
  i: integer;
386
begin
390
begin
387
  // In x86, the "cast" works with WideString.
391
  // In x86, the "cast" works with WideString.
388
  // In x64, it does not work (outputs empty string, without compiler warning!)
392
  // In x64, it does not work (outputs empty string, without compiler warning!)
Line 390... Line 394...
390
  SetLength(result, Length(x));
394
  SetLength(result, Length(x));
391
  for i := 0 to Length(x)-1 do
395
  for i := 0 to Length(x)-1 do
392
    result[i+1] := x[i];
396
    result[i+1] := x[i];
393
end;
397
end;
394
 
398
 
395
function AnsiCharArrayToWideString(x: array of AnsiChar): WideString;
399
function AnsiCharArrayToWideString(x: TAnsiCharArray): WideString;
396
var
400
var
397
  i: integer;
401
  i: integer;
398
begin
402
begin
399
  SetLength(result, Length(x));
403
  SetLength(result, Length(x));
400
  for i := 0 to Length(x)-1 do
404
  for i := 0 to Length(x)-1 do
Line 1392... Line 1396...
1392
{ TRbInfoAItem }
1396
{ TRbInfoAItem }
1393
 
1397
 
1394
procedure TRbInfoAItem.ReadFromStream(stream: TStream);
1398
procedure TRbInfoAItem.ReadFromStream(stream: TStream);
1395
var
1399
var
1396
  r: TRbInfoRecordA;
1400
  r: TRbInfoRecordA;
-
 
1401
  i: Integer;
1397
begin
1402
begin
1398
  stream.ReadBuffer(r, SizeOf(r));
1403
  stream.ReadBuffer(r, SizeOf(r));
1399
 
1404
 
1400
  FSourceDrive := Chr(Ord('A') + r.sourceDrive);
1405
  FSourceDrive := Chr(Ord('A') + r.sourceDrive);
1401
 
1406
 
Line 1410... Line 1415...
1410
    FRemovedEntry := true;
1415
    FRemovedEntry := true;
1411
    r.sourceAnsi[0] := AnsiChar(FSourceDrive);
1416
    r.sourceAnsi[0] := AnsiChar(FSourceDrive);
1412
  end;
1417
  end;
1413
 
1418
 
1414
  FSourceAnsi := r.sourceAnsi;
1419
  FSourceAnsi := r.sourceAnsi;
-
 
1420
 
-
 
1421
  // Unicode does not exist in INFO(1) structure
1415
  FSourceUnicode := AnsiCharArrayToWideString(r.sourceAnsi); // Unicode does not exist in INFO(1) structure
1422
  (* FSourceUnicode := AnsiCharArrayToWideString(r.sourceAnsi); *)
-
 
1423
  SetLength(FSourceUnicode, Length(r.sourceAnsi));
-
 
1424
  for i := 0 to Length(r.sourceAnsi)-1 do
-
 
1425
    FSourceUnicode[i+1] := WideChar(r.sourceAnsi[i]);
-
 
1426
 
1416
  FID := IntToStr(r.recordNumber);
1427
  FID := IntToStr(r.recordNumber);
1417
  FDeletionTime := FileTimeToDateTime(r.deletionTime);
1428
  FDeletionTime := FileTimeToDateTime(r.deletionTime);
1418
  FOriginalSize := r.originalSize;
1429
  FOriginalSize := r.originalSize;
1419
 
1430
 
1420
  // Remove #0 at the end. There are some bugs where #0 is added to ANSI/Unicode read paths?! (probably in the ReadVista stuff)
1431
  // Remove #0 at the end. There are some bugs where #0 is added to ANSI/Unicode read paths?! (probably in the ReadVista stuff)
Line 1547... Line 1558...
1547
 
1558
 
1548
procedure TRbVistaItem.ReadFromStream(stream: TStream);
1559
procedure TRbVistaItem.ReadFromStream(stream: TStream);
1549
var
1560
var
1550
  r1: TRbVistaRecord1;
1561
  r1: TRbVistaRecord1;
1551
  r2: TRbVistaRecord2Head;
1562
  r2: TRbVistaRecord2Head;
1552
  r2SourceUnicode: array of WideChar;
1563
  r2SourceUnicode: TWideCharArray;
1553
  version: DWORD;
1564
  version: DWORD;
-
 
1565
  i: Integer;
1554
begin
1566
begin
1555
  stream.ReadBuffer(version, SizeOf(version));
1567
  stream.ReadBuffer(version, SizeOf(version));
1556
 
1568
 
1557
  if version = 1 then
1569
  if version = 1 then
1558
  begin
1570
  begin
1559
    stream.Seek(0, soBeginning);
1571
    stream.Seek(0, soBeginning);
1560
    stream.ReadBuffer(r1, SizeOf(r1));
1572
    stream.ReadBuffer(r1, SizeOf(r1));
-
 
1573
 
-
 
1574
    (* FSourceAnsi := AnsiString(WideCharArrayToWideString(r1.sourceUnicode)); *)
-
 
1575
    SetLength(FSourceAnsi, Length(r1.sourceUnicode));
-
 
1576
    for i := 0 to Length(r1.sourceUnicode)-1 do
1561
    FSourceAnsi := AnsiString(WideCharArrayToWideString(r1.sourceUnicode)); // Invalid chars are automatically converted into '?'
1577
      FSourceAnsi[i+1] := AnsiChar(r1.sourceUnicode[i]); // Note: Invalid chars are automatically converted into '?'
-
 
1578
 
1562
    FSourceUnicode := WideCharArrayToWideString(r1.sourceUnicode);
1579
    (* FSourceUnicode := WideCharArrayToWideString(r1.sourceUnicode); *)
-
 
1580
    SetLength(FSourceUnicode, Length(r1.sourceUnicode));
-
 
1581
    for i := 0 to Length(r1.sourceUnicode)-1 do
-
 
1582
      FSourceUnicode[i+1] := r1.sourceUnicode[i];
-
 
1583
 
1563
    FID := ''; // will be added manually (at the constructor)
1584
    FID := ''; // will be added manually (at the constructor)
1564
    FSourceDrive := r1.sourceUnicode[1];
1585
    FSourceDrive := AnsiChar(r1.sourceUnicode[1]);
1565
    FDeletionTime := FileTimeToDateTime(r1.deletionTime);
1586
    FDeletionTime := FileTimeToDateTime(r1.deletionTime);
1566
    FOriginalSize := r1.originalSize;
1587
    FOriginalSize := r1.originalSize;
1567
  end
1588
  end
1568
  else if version = 2 then
1589
  else if version = 2 then
1569
  begin
1590
  begin
Line 1574... Line 1595...
1574
    stream.Read(r2SourceUnicode[0], SizeOf(WideChar)*(r2.sourceCountChars-1));
1595
    stream.Read(r2SourceUnicode[0], SizeOf(WideChar)*(r2.sourceCountChars-1));
1575
 
1596
 
1576
    FSourceAnsi := AnsiString(WideCharArrayToWideString(r2sourceUnicode)); // Invalid chars are automatically converted into '?'
1597
    FSourceAnsi := AnsiString(WideCharArrayToWideString(r2sourceUnicode)); // Invalid chars are automatically converted into '?'
1577
    FSourceUnicode := WideCharArrayToWideString(r2sourceUnicode);
1598
    FSourceUnicode := WideCharArrayToWideString(r2sourceUnicode);
1578
    FID := ''; // will be added manually (at the constructor)
1599
    FID := ''; // will be added manually (at the constructor)
1579
    FSourceDrive := r2sourceUnicode[1];
1600
    FSourceDrive := AnsiChar(r2sourceUnicode[1]);
1580
    FDeletionTime := FileTimeToDateTime(r2.deletionTime);
1601
    FDeletionTime := FileTimeToDateTime(r2.deletionTime);
1581
    FOriginalSize := r2.originalSize;
1602
    FOriginalSize := r2.originalSize;
1582
  end
1603
  end
1583
  else
1604
  else
1584
  begin
1605
  begin