Strange results...
Dir reports:
C:\Windows\System32\Macromed\Flash>dir
De volumenaam van station C is Packard Bell
Het volumenummer is 94AA-860B
Map van C:\Windows\System32\Macromed\Flash
25-03-2013 15:53 <DIR> .
25-03-2013 15:53 <DIR> ..
25-03-2013 15:49 646.611 activex.vch
25-03-2013 15:49 20.474.072 Flash64_11_6_602_180.ocx
25-03-2013 15:53 18.340 FlashInstall.log
25-03-2013 15:49 530.648 FlashUtil64_11_6_602_180_ActiveX.dll
25-03-2013 15:49 429.784 FlashUtil64_11_6_602_180_ActiveX.exe
25-03-2013 15:53 429.784 FlashUtil64_11_6_602_180_Plugin.exe
25-03-2013 15:53 20.275.416 NPSWF64_11_6_602_180.dll
25-03-2013 15:53 641.683 plugin.vch
8 bestand(en) 43.446.338 bytes
Test code:
program test;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
SysUtils, Classes, Windows;
Function FileExists (Const FileName : String) : String; //modified from SysUtils
var
Attr:Dword;
Res: Boolean;
Err: DWORD;
begin
Attr:=GetFileAttributes(PChar(FileName));
if Attr <> $ffffffff then
Res:= (Attr and FILE_ATTRIBUTE_DIRECTORY) = 0
else
Res:=False;
if Res then Result := 'True' else Result := 'False';
Result := Result + ', Attr = ' + IntToHex(Attr, 8);
if not Res then
begin
Err := GetLastError;
Result := Result + ' (GetLastError=' + IntToHex(Err,8) + ')';
end;
//Result := ExtractFileName(FileName) + ': ' + Result;
end;
var
DosError: LongInt;
Attr: Longint;
SR: TSearchRec;
SL: TStringList;
i: Integer;
const
FlashDir = 'C:\Windows\System32\Macromed\Flash\';
begin
SL := TStringList.Create;
if ParamStr(1) = '1' then
begin
writeln('Iterating ',FlashDir);
DosError := SysUtils.FindFirst(FlashDir + '*.*',faArchive or faReadOnly or faHidden or faSysFile ,SR);
while DosError = 0 do
begin
writeln('Found: "',SR.Name, '", Attr = ',IntToHex(SR.Attr,8));
//Sl.Add(SR.Name);
writeln('FileExists(',SR.Name,') = ',FileExists(FlashDir + SR.Name));
DosError := SysUtils.FindNext(SR);
end;
SysUtils.FindClose(SR);
end;
SL.Add('activex.vch');
SL.Add('Flash64_11_6_602_180.ocx');
SL.Add('FlashInstall.log');
SL.Add('FlashUtil64_11_6_602_180_ActiveX.dll');
SL.Add('FlashUtil64_11_6_602_180_ActiveX.exe');
SL.Add('FlashUtil64_11_6_602_180_Plugin.exe');
SL.Add('NPSWF64_11_6_602_180.dll');
SL.Add('plugin.vch');
writeln('----------------------');
for i := 0 to SL.Count - 1 do
begin
writeln('FileExists(',SL.Strings[i],') = ',FileExists(FlashDir + SL.Strings[i]));
end;
SL.Free;
end.
Output:
C:\Windows\System32\Macromed\Flash>\Users\Bart\LazarusProjecten\ConsoleProjecten
\test 1
Iterating C:\Windows\System32\Macromed\Flash\
Found: "activex.vch", Attr = 00000020
FileExists(activex.vch) = True, Attr = 00000020
Found: "Flash32_11_6_602_180.ocx", Attr = 00000021
FileExists(Flash32_11_6_602_180.ocx) = True, Attr = 00000021
Found: "FlashInstall.log", Attr = 00000020
FileExists(FlashInstall.log) = True, Attr = 00000020
Found: "flashplayer.xpt", Attr = 00000020
FileExists(flashplayer.xpt) = True, Attr = 00000020
Found: "FlashPlayerPlugin_11_6_602_180.exe", Attr = 00000020
FileExists(FlashPlayerPlugin_11_6_602_180.exe) = True, Attr = 00000020
Found: "FlashPlayerUpdateService.exe", Attr = 00000020
FileExists(FlashPlayerUpdateService.exe) = True, Attr = 00000020
Found: "FlashUtil32_11_6_602_180_ActiveX.dll", Attr = 00000020
FileExists(FlashUtil32_11_6_602_180_ActiveX.dll) = True, Attr = 00000020
Found: "FlashUtil32_11_6_602_180_ActiveX.exe", Attr = 00000020
FileExists(FlashUtil32_11_6_602_180_ActiveX.exe) = True, Attr = 00000020
Found: "FlashUtil32_11_6_602_180_Plugin.exe", Attr = 00000020
FileExists(FlashUtil32_11_6_602_180_Plugin.exe) = True, Attr = 00000020
Found: "install.log", Attr = 00000020
FileExists(install.log) = True, Attr = 00000020
Found: "mms.cfg", Attr = 00000020
FileExists(mms.cfg) = True, Attr = 00000020
Found: "NPSWF32_11_6_602_180.dll", Attr = 00000020
FileExists(NPSWF32_11_6_602_180.dll) = True, Attr = 00000020
Found: "plugin.vch", Attr = 00000020
FileExists(plugin.vch) = True, Attr = 00000020
----------------------
FileExists(activex.vch) = True, Attr = 00000020
FileExists(Flash64_11_6_602_180.ocx) = False, Attr = FFFFFFFF (GetLastError=00000002)
FileExists(FlashInstall.log) = True, Attr = 00000020
FileExists(FlashUtil64_11_6_602_180_ActiveX.dll) = False, Attr = FFFFFFFF (GetLastError=00000002)
FileExists(FlashUtil64_11_6_602_180_ActiveX.exe) = False, Attr = FFFFFFFF (GetLastError=00000002)
FileExists(FlashUtil64_11_6_602_180_Plugin.exe) = False, Attr = FFFFFFFF (GetLastError=00000002)
FileExists(NPSWF64_11_6_602_180.dll) = False, Attr = FFFFFFFF (GetLastError=00000002)
FileExists(plugin.vch) = True, Attr = 00000020
So, FindFirst finds the files, but GetFileAttributes reports the file is not there.
Even stranger, sometime when running the test program, FileExists reports the files are there ....
Bart