Delphi2010中的GetDir在Windows 7下不起作用?
我在 Delphi2010 中有以下命令序列:
var netdir:string;
....
OpenDialog1.InitialDir:=netdir;
....
OpenDialog1.Execute...
....
GetDir(0,netdir);
....
执行 OpenDialog 后,我应该在字符串 netdir 中包含我完成的目录 我的 OpenDialog.Execute。在下一个 OpenDialog.Execute 中应该从那里开始 目录。 在 XP 上运行正常,但在 Windows 7 上就不行? 它始终从程序安装的目录开始。
知道可能出了什么问题吗?
谢谢。
I have the following sequence of commands in Delphi2010:
var netdir:string;
....
OpenDialog1.InitialDir:=netdir;
....
OpenDialog1.Execute...
....
GetDir(0,netdir);
....
After executing OpenDialog I should have in string netdir the directory where I finished
my OpenDialog.Execute. And in the next OpenDialog.Execute it should start from that
directory.
It works fine on XP, but not on Windows 7?
It always starts from directory where the program is installed.
Any idea what might be wrong?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的问题无法按目前的情况得到回答,因为它缺少几个关键细节。
netdir
是全局常量,还是时常超出范围?netdir
设置为OpenDialog1.Execute
之前的内容?GetDir
返回什么目录(如标题所示),还是如何使打开的对话框记住上次访问的目录(如正文所示)?我假设 1) netdir 是一个全局常量,2) 您最初没有设置它,3) 您希望打开的对话框记住上次访问的文件夹。因此你有类似的东西
那么解决方案是让Windows为你记住目录,即简单地
单独做!但为什么你的方法不起作用呢?好吧,
GetDir
不会返回您想要的内容。如果您需要显式控制,请执行Your question cannot be answered as it stands, because it lacks several crucial details.
netdir
a global constant, or does it go out of scope every now and then?netdir
to something prior toOpenDialog1.Execute
?GetDir
return (as your title suggests), or about how to make the open dialog remember the last visited directory (as the body matter suggests)?I will assume that 1)
netdir
is a global constant, that 2) you do not set it initially, and that 3) you want the open dialog to remember the last visited folder. Thus you have something likeThen the solution is to let Windows remember the directory for you, that is, simply do
alone! But why doesn't your method work? Well,
GetDir
doesn't return what you want. If you need explicit control, do如果您不想打开对话框,您可以执行以下操作以获取程序下的目录。
我已经在 Vista 中完成了,并且有效。
If you not wan´t opendialog you can do as below to get dir under your program.
I have done it in Vista and it work.
这是问题的解决方案
This is the solution for the problem