How to change ExtractFilePath(Application.ExeName) back?

I am writing a program, the user could
change skin of the program, I put the
exe file in c:\temp, and skin files in
c:\temp\skins, when user run this program, the
ExtractFilePath(Application.ExeName) is
c:\temp
After user click 'change skin' button, I use following procedure open a dialog
let user select skin.ini file:

procedure TForm1.cmSkinClick(Sender: TObject);
var   SkinsDlg : TOpenDialog;
begin
     SkinsDlg := TOpenDialog.Create(self);
     SkinsDlg.InitialDir := ExtractFilePath(Application.ExeName)+'Skins';
     SkinsDlg.Filter := 'Skin files (*.ini)|*.ini';
     if SkinsDlg.Execute then
     begin
          SkinForm1.LoadSkinFile(SkinsDlg.FileName);  //Change the skin
     end;
     SkinsDlg.Free;
end;


The problem is after user change skin,
the ExtractFilePath(Application.ExeName)
is c:\temp\skin, how to change it back
to c:\temp?

Thanks & Rgds

Chiwan
chiwanAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
EpsylonConnect With a Mentor Commented:
Set the [ofNoChangeDir] option to true in SkinsDlg.Options.

In code: SkinsDlg.Options := SkinsDlg.Options + ofNoChangeDir
0
 
florisbCommented:
Same problem if you use ExtractFilePath(ParamStr(0))?

And if you set the initial dir before you do OpenDialog?

Floris.

0
 
she3i3iCommented:
Chiwan,

ExtractFilePath(Application.ExeName) is not something that you can change thus I do not understand why you are getting this problem. Try assigning the Executable's path to a variable and then use that. Like so:

procedure TForm1.cmSkinClick(Sender: TObject);
var
   SkinsDlg : TOpenDialog;
   CurDir : String;
begin
   SkinsDlg := TOpenDialog.Create(self);
   CurDir := ExtractFilePath(Application.ExeName);
   SkinsDlg.InitialDir := (CurDir+'Skins');
   SkinsDlg.Filter := 'Skin files (*.ini)|*.ini';
   if SkinsDlg.Execute then begin
      SkinForm1.LoadSkinFile(SkinsDlg.FileName);  //Change the skin
   end;
   SkinsDlg.Free;
end;

Hope this helps,

Chris.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
ckanetaCommented:
you could just call ExtractFilePath(application.exename) once when the program starts and store it in a variable(since the actual location of the .exe will not change during the course of running your program)
0
 
EpsylonCommented:
are u there?
0
 
EpsylonCommented:
Ding dong!!!!!!
0
 
EpsylonCommented:
Please grade!
0
 
EpsylonCommented:
Please grade!
0
 
EpsylonCommented:
Please grade!
0
 
florisbCommented:
YEAH!
0
 
EpsylonCommented:
Another blacklist candidate..?
0
 
EpsylonCommented:
Chiwan, you are a waste of time......
0
 
chiwanAuthor Commented:
EPsylon
I am sorry, reply so later, my internet
connection was cut by our telecom. company because some argument between my boss and them.
Now I am in another city.
Live is not easy.
0
All Courses

From novice to tech pro — start learning today.