Get the current directory  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 15/07/99

Tip accessed 562 times

 


Put a TLabel (Label1) and into OnCLick event of a button, put this code:


 procedure TForm1.Button7Click(Sender: TObject);
   function GetCurrentDirectory: String;
   var
      nBufferLength : DWORD;
      lpBuffer 	 : PChar;
   begin
      nBufferLength := MAX_PATH + 1;
      GetMem( lpBuffer, nBufferLength );
      try
         if Windows.GetCurrentDirectory( nBufferLength, lpBuffer ) > 0 then
            Result := lpBuffer;
      finally
         FreeMem( lpBuffer );
      end;
   end;
 begin
   Label1.Caption:=GetCurrentDirectory;
 end;