OSDN Git Service

Check if ghost file exists on startup
[winbottle/svg-dll.git] / SVG.dpr
diff --git a/SVG.dpr b/SVG.dpr
index ef2f7d8..73fe218 100644 (file)
--- a/SVG.dpr
+++ b/SVG.dpr
@@ -8,7 +8,7 @@ library SVG;
 {$R *.res}
 
 uses
-  Windows, Classes, SysUtils, Graphics, IniFiles;
+  Windows, Classes, SysUtils, Graphics, IniFiles, Dialogs;
 
 const
   SurfaceWidth  = 48;
@@ -36,6 +36,8 @@ begin
   finally
     Ini.Free;
   end;
+  if not FileExists(GhostFile) then
+    ShowMessage('SVG.dll Warning: Ghost file is not specified');
   Ghost2File := TStringList.Create;
 end;
 
@@ -55,7 +57,7 @@ end;
 // CanConfigure\82Í\81AConfigure\82ð\8cÄ\82Î\82ê\82Ä\82â\82é\82±\82Æ\82ª\82 \82é\82©\82Ç\82¤\82©\82ð\95Ô\82·\81B
 function GetVersion(DLLName: PChar; NameLen: integer;
   var Version: integer; var CanConfigure: boolean): integer; cdecl;
-const ThisDLL = 'SVG Surface Loader for Ver. 1';
+const ThisDLL = 'SVG Surface Loader for Ver. 1.1';
 begin
   Version := 1;
   CanConfigure := true;
@@ -243,7 +245,34 @@ end;
 // DLL\8cÅ\97L\82Ì\90Ý\92è\82ð\8ds\82¤\81B
 //
 procedure Configure; cdecl;
+var OpenDialog: TOpenDialog;
+    Ini: TIniFile;
 begin
+  try
+    ShowMessage('Specify SSTP Viewer''s ghost file.');
+    OpenDialog := TOpenDialog.Create(nil);
+    try
+      OpenDialog.Filter := 'Ghost Definition File(ghost.txt)|ghost.txt|' +
+       'All Files(*.*)|*.*';
+      OpenDialog.FileName := GhostFile;
+      if OpenDialog.Execute then
+      begin
+        GhostFile := OpenDialog.FileName;
+        Ini := TIniFile.Create(MyPath + ConfigFile);
+        try
+          Ini.WriteString('SVG', 'GhostFile', GhostFile);
+        finally
+          Ini.Free;
+        end;
+        Ghost2File.Clear;
+      end;
+    finally
+      OpenDialog.Free;
+    end;
+  except
+    on E: Exception do
+      ShowMessage(E.Message);
+  end;
 end;
 
 exports