AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi FileExists und Vista 64 Bit funktioniert nicht ?
Thema durchsuchen
Ansicht
Themen-Optionen

FileExists und Vista 64 Bit funktioniert nicht ?

Ein Thema von TKC · begonnen am 9. Jan 2009 · letzter Beitrag vom 10. Jan 2009
Antwort Antwort
Benutzerbild von TKC
TKC

Registriert seit: 21. Apr 2004
Ort: Tuningen
367 Beiträge
 
Delphi XE2 Enterprise
 
#1

FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 9. Jan 2009, 22:26
Hallo,

ich teste gerade Delphi 2009 auf Vista 64 Bit und habe ein kleines Problem festgestellt.
Delphi und Vista sind auf dem aktuellen Stand.

Wenn ich die Funktion FileExists() in einem Windows Ordner benutze gibt sie immer False zurrück.

z.B.:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin

  if FileExists('C:\windows\system32\drivers\kbdclass.sys') then
    ShowMessage('ok');

end;
Die Datei existiert natürlich !

In anderen Ordnern funktioniert es normal.

Was ist da das Problem und wie umgehe ich das ?
  Mit Zitat antworten Zitat
jbg

Registriert seit: 12. Jun 2002
3.481 Beiträge
 
Delphi 10.1 Berlin Professional
 
#2

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 9. Jan 2009, 22:33
Zitat von TKC:
Die Datei existiert natürlich !
Probiere es mal mit dem echten "System32" Ordner: C:\Windows\SysWOW64
  Mit Zitat antworten Zitat
Benutzerbild von TKC
TKC

Registriert seit: 21. Apr 2004
Ort: Tuningen
367 Beiträge
 
Delphi XE2 Enterprise
 
#3

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 9. Jan 2009, 22:36
Hilft leider nichts ... gleiches Problem.
  Mit Zitat antworten Zitat
Benutzerbild von Meflin
Meflin

Registriert seit: 21. Aug 2003
4.856 Beiträge
 
#4

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 9. Jan 2009, 22:38
Hatte heute ein ganz ähnliches Phänomen: Ich hätte einen Treiber in einem Open-Dialog auswählen sollen - aber da waren keine, obwohl natürlich im Verzeichnis vorhanden
  Mit Zitat antworten Zitat
Benutzerbild von TKC
TKC

Registriert seit: 21. Apr 2004
Ort: Tuningen
367 Beiträge
 
Delphi XE2 Enterprise
 
#5

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 10. Jan 2009, 03:57
So ... ich habe es jetzt mal so gelöst ...

Delphi-Quellcode:
function FileExists64NoRedirection(Filename: string): Boolean;
type
  TWow64DisableWow64FsRedirection = function(var Wow64FsEnableRedirection: LongBool): LongBool; StdCall;
  TWow64RevertWow64FsRedirection = function(var Wow64FsEnableRedirection: LongBool): LongBool; StdCall;

var
  hHandle: THandle;
  Wow64DisableWow64FsRedirection: TWow64DisableWow64FsRedirection;
  Wow64RevertWow64FsRedirection: TWow64RevertWow64FsRedirection;
  Wow64FsEnableRedirection: LongBool;
  Is64BitWin: boolean;

begin
  Is64BitWin := False;
  Wow64DisableWow64FsRedirection := nil;
  Wow64RevertWow64FsRedirection := nil;

  try
    hHandle := GetModuleHandle('kernel32.dll');
    @Wow64RevertWow64FsRedirection := GetProcAddress(hHandle, 'Wow64RevertWow64FsRedirection');
    @Wow64DisableWow64FsRedirection := GetProcAddress(hHandle, 'Wow64DisableWow64FsRedirection');


    if ((hHandle <> 0) and (@Wow64RevertWow64FsRedirection <> nil) and (@Wow64DisableWow64FsRedirection <> nil)) then
      Is64BitWin := True;

  except
    Is64BitWin := False;
  end;

  if Is64BitWin then
    begin
      Wow64DisableWow64FsRedirection(Wow64FsEnableRedirection);
      Result := FileExists(Filename);
      Wow64RevertWow64FsRedirection(Wow64FsEnableRedirection);
    end
  else
    Result := FileExists(Filename);

end;
Es liegt wohl an der "File system redirection" von 64 Bit Systemen, die im System32 Ordner und anderen aktiv ist.

Aber irgendwie denke ich, das CG das mal etwas anpassen sollte.
Ich bin noch für andere Lösungen offen.
  Mit Zitat antworten Zitat
Benutzerbild von jfheins
jfheins

Registriert seit: 10. Jun 2004
Ort: Garching (TUM)
4.579 Beiträge
 
#6

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 10. Jan 2009, 09:48
Vll. das hier:
Zitat:
Starting with Windows Vista, 32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a special alias used to indicate that the file system should not redirect the access. This mechanism is flexible and easy to use, therefore, it is the recommended mechanism to bypass file system redirection. Note that 64-bit applications cannot use the Sysnative alias as it is a virtual directory not a real one.
http://msdn.microsoft.com/en-us/libr...87(VS.85).aspx
  Mit Zitat antworten Zitat
mjustin

Registriert seit: 14. Apr 2008
3.004 Beiträge
 
Delphi 2009 Professional
 
#7

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 10. Jan 2009, 11:09
Zitat von TKC:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin

  if FileExists('C:\windows\system32\drivers\kbdclass.sys') then
    ShowMessage('ok');

end;
Mit GetSystemDirectory (oder GetWindowsSystemFolder aus der JCL) sollte sich das Windows System Verzeichnis ermitteln lassen, ich habe leider kein Vista 64 zum Testen hier.
Michael Justin
habarisoft.com
  Mit Zitat antworten Zitat
Dezipaitor

Registriert seit: 14. Apr 2003
Ort: Stuttgart
1.701 Beiträge
 
Delphi 7 Professional
 
#8

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 10. Jan 2009, 13:06
Vista leitet diesen Zugriff auf das Wow64 (oder so ähnlich) Verzeichnis um. Darin sind die 32bit Dateien.
Christian
Windows, Tokens, Access Control List, Dateisicherheit, Desktop, Vista Elevation?
Goto: JEDI API LIB & Windows Security Code Library (JWSCL)
  Mit Zitat antworten Zitat
Benutzerbild von Meflin
Meflin

Registriert seit: 21. Aug 2003
4.856 Beiträge
 
#9

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 10. Jan 2009, 13:12
Zitat von Dezipaitor:
Vista leitet diesen Zugriff auf das Wow64 (oder so ähnlich) Verzeichnis um. Darin sind die 32bit Dateien.
Auch wenns jetz nix mit dem Thema zu tun hat: Das sollte aber dann doch auch aus einem Öffnen-Dialog heraus funktionieren - der wurde bie mir scheinbar nicht umgeleitet?!
  Mit Zitat antworten Zitat
Dezipaitor

Registriert seit: 14. Apr 2003
Ort: Stuttgart
1.701 Beiträge
 
Delphi 7 Professional
 
#10

Re: FileExists und Vista 64 Bit funktioniert nicht ?

  Alt 10. Jan 2009, 14:27
Vielleicht schaltet der Dialog das Umleiten aus? Oder hast du es ausgeschaltet? Oder du wurdest einfach reingelegt?
Erzeuge doch mal mit dem Explorer eine Datei im echten 64bit Ordner und versuche sie zu finden mit nem 32bit Prog.
Christian
Windows, Tokens, Access Control List, Dateisicherheit, Desktop, Vista Elevation?
Goto: JEDI API LIB & Windows Security Code Library (JWSCL)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:34 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz