Powerbuilder查询

Goo*_*ill 4 powerbuilder

如何使用PowerBuilder中的文件函数搜索任何目录中的.txt文件(即c:\,d:\ etc.)?

Ter*_*rry 6

所以,如果您正在查找文件,可以使用listbox.DirList()执行此操作,或者如果您希望在不依赖于窗口或控件的情况下执行此操作,则可以调用WinAPI函数来执行此操作:

Function long FindFirstFileW (ref string filename, ref os_finddata findfiledata) library "KERNEL32.DLL" alias for "FindFirstFileW"
Function boolean FindNextFileW (long handle, ref os_finddata findfiledata) library "KERNEL32.DLL" alias for "FindNextFileW"
Run Code Online (Sandbox Code Playgroud)

其中os_finddata定义为

unsignedlong        ul_fileattributes
os_filedatetime     str_creationtime
os_filedatetime     str_lastaccesstime
os_filedatetime     str_lastwritetime
unsignedlong        ul_filesizehigh
unsignedlong        ul_filesizelow
unsignedlong        ul_reserved0
unsignedlong        ul_reserved1
character       ch_filename[260]
character       ch_alternatefilename[14]
Run Code Online (Sandbox Code Playgroud)

和os_filedatetime定义为

unsignedlong        ul_lowdatetime
unsignedlong        ul_highdatetime
Run Code Online (Sandbox Code Playgroud)

如果您需要有关如何使用它们的示例,请查看对象(pfcapsrv.pbl)pfc_n_cst_filesrvunicode.of_DirList()中的PFC(PowerBuilder基础类,可从CodeXchange获得).(这就是这些原型和结构从BTW复制的地方.)

祝好运,

特里