How to change driver letter at runtime in delphi

1

Friends, I decided to simplify the use of a system in Delphi , using banco de dados and the executable available in a file in pen drive . With this, I have my tables in Access , and arranged in a DataModule with ADOQuery , with connection aligned with the E: drive, for example.

It happens that when I connect the drive in another pc will not always recognize this pen drive as "E:" , and can automatically set another letter. I know how to change the letter through windows but if you have restriction to access this feature, it gets complicated.

So, I want to insert a Combobox that allows to adjust my program with the letter that is indicated in the use pc, or even if program the recognition and adjust automatically as soon as initialized.

I count on the help of my colleagues, if that is possible. Thankful.

    
asked by anonymous 12.01.2016 / 20:08

1 answer

3

Why instead of using absolute path ( e:\app\base\arquivo.mdb ), you do not use relative path to access your bank ( base\arquivo.mdb )? That would solve your problem.

If you still want to know how to drive your pendrive, you can use the command ExtractFileDrive(ParamStr(0)) .

    
12.01.2016 / 20:30