当前位置: 代码迷 >> VFP >> VFP程序路径设置程序,该怎么处理
  详细解决方案

VFP程序路径设置程序,该怎么处理

热度:3193   发布时间:2013-02-26 00:00:00.0
VFP程序路径设置程序
说明:用到了 filer.dll,所以,如果使用以下程序,该文件需要随同 EXE 一同发布。


Local LcMyDrive ,LcPath, LoPathSearch

m.LcMyDrive = Sys(5) + Sys(2003) + [\]
Set Default To (m.LcMyDrive)

Try
  m.LoPathSearch = Createobject([filer.fileutil])
Catch
  Run /N REGSVR32 /s "filer.dll"
  m.LoPathSearch = Createobject([filer.fileutil])  
EndTry

With m.LoPathSearch
  .FileExpression = [*.*]
  .SearchPath = m.LcMyDrive
  .SubFolder = .T.
  .Find(1)
EndWith 

Create Cursor MyPath(cpath c(254))

For m.i = 1 to m.LoPathSearch.Files.Count
  Insert into MyPath(cpath) values(m.LoPathSearch.Files[m.i].Path)
EndFor 

Select DISTINCT * From MyPath into cursor MyPath2

Select MyPath2
m.LcMyPath = []
Scan
  m.LcMyPath = m.LcMyPath + Alltrim(MyPath2.cpath) + [,]
EndScan 

m.LcMyPath = Left(m.LcMyPath, Len(m.LcMyPath) - 1)

Use in MyPath2
Use in MyPath

Set Path To (m.LcMyPath) Additive

------解决方案--------------------------------------------------------
发表一点看法,不对请指正。
1.如下两句似乎不妥
m.LcMyDrive = Sys(5) + Sys(2003) + [\]
Set Default To (m.LcMyDrive)

第一句取得当前路径,第二句把当前路径设置为当前路径。好比问:“李先生,您贵姓?”
俺以为除非两句之间CD到其他路径去了,前面SYS后面再Set Default回来才有意义。

2.单从为了获取当前程序所在目录中的所有子目录路径,ADIR就很不错了,好像没有必要DLL。除非路径嵌套较深,要获取整个当前目录树的全部目录节点。而一般项目在项目目录下包含一层子目录的两层目录结构差不多够用了。

3.set path 是方便,设置好了只管use dbf、do prg,系统自己找去,不过效率却不如带部分路径的命令,比如x.scx在项目目录下的forms子目录,用do form forms\x.scx比设了一长串path后用do form x.scx来的快。当然现在机器快,这点效率优势被忽略了。

4.楼主程序后面不如浓缩一下

m.LcMyPath=""
For m.i = 1 to m.LoPathSearch.Files.Count
m.LcMyPath=m.LoPathSearch.Files[m.i].Path + [,] + m.LcMyPath
EndFor
Set Path To (m.LcMyPath) Additive
  相关解决方案