Subversion Repositories recyclebinunit

Rev

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

Rev 23 Rev 24
Line 1... Line 1...
1
////////////////////////////////////////////////////////////////////////////////////
1
////////////////////////////////////////////////////////////////////////////////////
2
// RECYCLE-BIN-FUNCTIONS BY DANIEL MARSCHALL                                      //
2
// RECYCLE-BIN-FUNCTIONS BY DANIEL MARSCHALL                                      //
3
// E-MAIL: info@daniel-marschall.de                                               //
3
// E-MAIL: info@daniel-marschall.de                                               //
4
// WEB:    www.daniel-marschall.de                                                //
4
// WEB:    www.daniel-marschall.de                                                //
5
////////////////////////////////////////////////////////////////////////////////////
5
////////////////////////////////////////////////////////////////////////////////////
6
// Revision: 18 JUN 2010                                                          //
6
// Revision: 04 JUL 2010                                                          //
7
// This unit is freeware, but please link to my website if you are using it!      //
7
// This unit is freeware, but please link to my website if you are using it!      //
8
////////////////////////////////////////////////////////////////////////////////////
8
////////////////////////////////////////////////////////////////////////////////////
9
// Successful tested with:                                                        //
9
// Successful tested with:                                                        //
10
// Windows 95b, 95b + IE4, 98-SE, XP-SP2, 2000-SP4, 2003-SRV-EE-SP1, VISTA        //
10
// Windows 95b, 95b + IE4, 98-SE, XP-SP2, 2000-SP4, 2003-SRV-EE-SP1, VISTA        //
11
////////////////////////////////////////////////////////////////////////////////////
11
////////////////////////////////////////////////////////////////////////////////////
Line 374... Line 374...
374
 
374
 
375
resourcestring
375
resourcestring
376
  LNG_UNEXPECTED_STATE = 'Cannot determinate state of "%s" because of an unknown value in the configuration of your operation system. Please contact the developer of the Recycler Bin Unit and help improving the determination methods!';
376
  LNG_UNEXPECTED_STATE = 'Cannot determinate state of "%s" because of an unknown value in the configuration of your operation system. Please contact the developer of the Recycler Bin Unit and help improving the determination methods!';
377
  LNG_API_CALL_ERROR = 'Error while calling the API. Additional information: "%s".';
377
  LNG_API_CALL_ERROR = 'Error while calling the API. Additional information: "%s".';
378
  LNG_NOT_CALLABLE = '%s not callable';
378
  LNG_NOT_CALLABLE = '%s not callable';
379
  LNG_ERROR_CODE = '%s returns error code %s';
379
  LNG_ERROR_CODE = '%s (Arguments: %s) returns error code %s';
380
 
380
 
381
function _GetBit(B: Byte; BitPos: TBitPos): boolean; overload;
381
function _GetBit(B: Byte; BitPos: TBitPos): boolean; overload;
382
var
382
var
383
  p: byte;
383
  p: byte;
384
begin
384
begin
Line 2780... Line 2780...
2780
  Drive: Char;
2780
  Drive: Char;
2781
begin
2781
begin
2782
  result := true;
2782
  result := true;
2783
  for Drive := 'A' to 'Z' do
2783
  for Drive := 'A' to 'Z' do
2784
  begin
2784
  begin
2785
    if not RecyclerIsEmpty(Drive) then
2785
    if RecyclerIsPossible(Drive) and not RecyclerIsEmpty(Drive) then
2786
    begin
2786
    begin
2787
      result := false;
2787
      result := false;
2788
      exit;
2788
      exit;
2789
    end;
2789
    end;
2790
  end;
2790
  end;
Line 2800... Line 2800...
2800
  Drive: Char;
2800
  Drive: Char;
2801
begin
2801
begin
2802
  result := 0;
2802
  result := 0;
2803
  for Drive := 'A' to 'Z' do
2803
  for Drive := 'A' to 'Z' do
2804
  begin
2804
  begin
-
 
2805
    if RecyclerIsPossible(Drive) then
-
 
2806
    begin
2805
    result := result + RecyclerGetNumItems(Drive);
2807
      result := result + RecyclerGetNumItems(Drive);
2806
  end;
2808
    end;
2807
end;
2809
  end;
-
 
2810
end;
2808
 
2811
 
2809
function RecyclerGetNumItems(Drive: Char): int64;
2812
function RecyclerGetNumItems(Drive: Char): int64;
2810
begin
2813
begin
2811
  result := RecyclerGetAPIInfo(Drive).i64NumItems;
2814
  result := RecyclerGetAPIInfo(Drive).i64NumItems;
2812
end;
2815
end;
Line 2816... Line 2819...
2816
  Drive: Char;
2819
  Drive: Char;
2817
begin
2820
begin
2818
  result := 0;
2821
  result := 0;
2819
  for Drive := 'A' to 'Z' do
2822
  for Drive := 'A' to 'Z' do
2820
  begin
2823
  begin
-
 
2824
    if RecyclerIsPossible(Drive) then
-
 
2825
    begin
2821
    result := result + RecyclerGetSize(Drive);
2826
      result := result + RecyclerGetSize(Drive);
2822
  end;
2827
    end;
2823
end;
2828
  end;
-
 
2829
end;
2824
 
2830
 
2825
function RecyclerGetSize(Drive: Char): int64;
2831
function RecyclerGetSize(Drive: Char): int64;
2826
begin
2832
begin
2827
  result := RecyclerGetAPIInfo(Drive).i64Size;
2833
  result := RecyclerGetAPIInfo(Drive).i64Size;
2828
end;
2834
end;
Line 2870... Line 2876...
2870
    if res = S_OK then
2876
    if res = S_OK then
2871
    begin
2877
    begin
2872
      // Alles OK, unser result hat nun die gewünschten Daten.
2878
      // Alles OK, unser result hat nun die gewünschten Daten.
2873
    end
2879
    end
2874
    else
2880
    else
-
 
2881
    begin
-
 
2882
      // Since Windows Vista, SHQueryRecycleBin will fail with E_FAIL (80004005)
-
 
2883
      // if Path is a floppy or CD drive...
2875
      raise EAPICallError.CreateFmt(LNG_API_CALL_ERROR, [Format(LNG_ERROR_CODE, [C_SHQueryRecycleBin, '0x'+IntToHex(res, 2*SizeOf(HRESULT))])]);
2884
      raise EAPICallError.CreateFmt(LNG_API_CALL_ERROR, [Format(LNG_ERROR_CODE, [C_SHQueryRecycleBin, Path, '0x'+IntToHex(res, 2*SizeOf(HRESULT))])]);
-
 
2885
    end;
2876
  end
2886
  end
2877
  else
2887
  else
2878
    raise EAPICallError.CreateFmt(LNG_API_CALL_ERROR, [Format(LNG_NOT_CALLABLE, [C_SHQueryRecycleBin])]);
2888
    raise EAPICallError.CreateFmt(LNG_API_CALL_ERROR, [Format(LNG_NOT_CALLABLE, [C_SHQueryRecycleBin])]);
2879
 
2889
 
2880
  if (RBHandle <> 0) then FreeLibrary(RBHandle);
2890
  if (RBHandle <> 0) then FreeLibrary(RBHandle);
Line 3056... Line 3066...
3056
  result := typ = DRIVE_FIXED;
3066
  result := typ = DRIVE_FIXED;
3057
end;
3067
end;
3058
 
3068
 
3059
function RecyclerLibraryVersion: string;
3069
function RecyclerLibraryVersion: string;
3060
begin
3070
begin
3061
  result := 'ViaThinkSoft Recycle Bin Unit [18 JUN 2010]';
3071
  result := 'ViaThinkSoft Recycle Bin Unit [04 JUL 2010]';
3062
end;
3072
end;
3063
 
3073
 
3064
end.
3074
end.