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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

EpsylonCommented:
Set the [ofNoChangeDir] option to true in SkinsDlg.Options.

In code: SkinsDlg.Options := SkinsDlg.Options + ofNoChangeDir
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.