04‏/02‏/2013

How to get System Directory Name using delphi

How to get System Directory using delphi !!


Hello every one , in this topic I'll represent to you the Function responsible for getting System directory Full Name !!


First : 

You have to use those library in delphi :

In delphi 7 version : use those   ( Windows, SysUtils, Classes, IOUtils
In delphi Xe2 and higher : use those space-names  ( Winapi.Windows, System.SysUtils, System.Classes, IOUtils )

Go to the uses section code and type :
uses
    Windows, SysUtils, Classes, IOUtils;

Second : 

And then go to the Implementation section and type this function :
function GetSystemDir: AnsiString;
var
  buf: array [0 .. MAX_PATH] of Char;
begin
  GetSystemDirectory(buf, SizeOf(buf));
  result := AnsiString(buf);
end;


How Can I  use this ?


with a simple call .....
GetSystemDir()
  the function retrun the full name of system directory
in a format of AnsiString
you can convert to string and any other format !! it not a problem .

Thank you. 



0 commentaires:

إرسال تعليق