Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#9
  Alt 2. Jun 2003, 16:19
So. Probiert noch mal. Ich habe da jetzt was gedreht. Der Code sieht jetzt so aus:
Delphi-Quellcode:
const
        OPENFILENAME_SIZE_VERSION_400 : Cardinal = $000004C;

function IsNT5OrHigher: Boolean;
var
  ovi: TOSVERSIONINFO;
begin
  ZeroMemory(@ovi, sizeof(TOSVERSIONINFO));
  ovi.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFO);
  GetVersionEx(ovi);
  if (ovi.dwPlatformId = VER_PLATFORM_WIN32_NT) AND (ovi.dwMajorVersion >= 5) then
    result := TRUE
  else
    result := FALSE;
end;

{-----------------------------------------------------------------------------
  Procedure : OpenFile - 2003-06-01 03:45:47
  modified  : 2003-06-01
  Author    : Michael Puff
  Purpose  : OpenFileDialog for file to split
  Arguments : None
  Result    : string
-----------------------------------------------------------------------------}


function OpenFile : string;
var
  ofn : TOpenFilename;
  Buffer : array[0..MAX_PATH - 1] of Char;
begin
  result := '';
  ZeroMemory(@Buffer[0], sizeof(Buffer));
  ZeroMemory(@ofn, sizeof(TOpenFilename));
  if IsNT5OrHigher then
    ofn.lStructSize := sizeof(TOpenFilename)
  else
    ofn.lStructSize := sizeof(OPENFILENAME_SIZE_VERSION_400);
  ofn.hWndOwner := hApp;
  ofn.hInstance := hInstance;
  ofn.lpstrFile := @Buffer[0];
  ofn.nMaxFile := sizeof(Buffer);
  ofn.Flags := OFN_LONGNAMES;

  { Datei-Öffnen-Dialog aufrufen }
  if GetOpenFileName(ofn) then
    result := ofn.lpstrFile;
end;
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat