The following code is the code to check the existence of files located in the same folder with the program.
Double click the OnCreate event.enter following code :
Double click the OnCreate event.enter following code :
procedure TFormLogin.FormCreate(Sender: TObject);
var FileName1, FileName2: string;
begin
FileName1 := 'dbxopenmysql50.dll';
FileName2 := 'libmysql.dll';
ExtractFilePath(Application.ExeName);
if (FileExists(FileName1) = false ) or (FileExists(FileName2) = false) then
begin
MessageDlg('File '+FileName1+' atau '+FileName2+' tidak dapat ditemukan', mtError, [mbOK], 0);
Application.Terminate;
end;
end;
Explanation :The script above is a script to check a file via the variable that contains the FileName1 contains dbopenmysql50.dll and Filename2 contains libmysql.dll. The ExtractFilePath(Application.ExeName) is a function to locate in what folder on the which drive the application is stored, the FileExist inside if function used to check whether the contents of the variable from FileName1 and FileName2 exist, if one from the both variable FileName1 and FileName2 is false the error dialog will displayed and the application will be terminated, but if both condition is true, the application will continue.
Hopefuly the article is helpful.
Hopefuly the article is helpful.

0 comments:
Post a Comment