delphi - GetDir in Delphi2010 not working under Windows 7? -


i have following sequence of commands in delphi2010:

  var netdir:string;   ....   opendialog1.initialdir:=netdir;   ....   opendialog1.execute...   ....   getdir(0,netdir);   .... 

after executing opendialog should have in string netdir directory finished opendialog.execute. , in next opendialog.execute should start directory. works fine on xp, not on windows 7? starts directory program installed.

any idea might wrong?

thanks.

your question cannot answered stands, because lacks several crucial details.

  1. is netdir global constant, or go out of scope every , then?
  2. do set netdir prior opendialog1.execute?
  3. is question directory getdir return (as title suggests), or how make open dialog remember last visited directory (as body matter suggests)?

i assume 1) netdir global constant, 2) not set initially, , 3) want open dialog remember last visited folder. have like

unit unit3;  interface  uses   windows, messages, sysutils, variants, classes, graphics, controls, forms,   dialogs;  type   tform3 = class(tform)     opendialog1: topendialog;     procedure formclick(sender: tobject);   private     { private declarations }   public     { public declarations }   end;  var   form3: tform3;  var   netdir: string;  implementation  {$r *.dfm}  procedure tform3.formclick(sender: tobject); begin   opendialog1.initialdir := netdir;   opendialog1.execute;   getdir(0, netdir); end;  end. 

then solution let windows remember directory you, is, do

procedure tform3.formclick(sender: tobject); begin   opendialog1.execute; end; 

alone! why doesn't method work? well, getdir doesn't return want. if need explicit control, do

procedure tform3.formclick(sender: tobject); begin   opendialog1.initialdir := netdir;   opendialog1.execute;   netdir := extractfilepath(opendialog1.filename) end; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -