| 发表于:2007-07-10 16:42:215楼 得分:0 |
'api函数声明: public declare function findfirstfile lib "kernel32 " alias "findfirstfilea " (byval lpfilename as string, lpfindfiledata as win32_find_data) as long public declare function findnextfile lib "kernel32 " alias "findnextfilea " (byval hfindfile as long, lpfindfiledata as win32_find_data) as long public declare function findclose lib "kernel32 " (byval hfindfile as long) as long '结构及变量类型声明: public type win32_find_data dwfileattributes as long ftcreationtime as filetime ftlastaccesstime as filetime ftlastwritetime as filetime nfilesizehigh as long nfilesizelow as long dwreserved0 as long dwreserved1 as long cfilename as string * max_path calternate as string * 14 end type public const ftp_transfer_type_binary = &h2 public const internet_flag_no_cache_write = &h4000000 public const format_message_allocate_buffer = &h100 public const format_message_from_system = &h1000 public const format_message_ignore_inserts = &h200 public const invalid_handle_value = -1 public const file_attribute_directory = &h10 public const internet_flag_dont_cache = &h4000000 public const cns_filename_delimeter = "/ " public const files_without_dir = 1 public const files_with_dir = 2 public const files_only_dir = 3 public const files_only_dir_including_dot = 4 public function getfilesindir(dirpath as string, strtype as string, withdir as integer) as string dim hf as long dim str as string dim strtmp as string dim filedata as win32_find_data if strtype = " " then strtype = "* " end if hf = findfirstfile(dirpath & "\*. " & strtype, filedata) if hf <> invalid_handle_value then str = stripnulls(filedata.cfilename) if (str = ". " or str = ".. ") and withdir <> files_only_dir_including_dot then str = " " end if if withdir = files_without_dir then if str <> " " and (filedata.dwfileattributes and file_attribute_directory) then str = " " end if do while findnextfile(hf, filedata) <> 0 strtmp = stripnulls(filedata.cfilename) if strtmp <> ". " and strtmp <> ".. " and (filedata.dwfileattributes and file_attribute_directory) = 0 then str = str & cns_filename_delimeter & strtmp end if loop elseif withdir = files_only_dir then if str <> " " and (filedata.dwfileattributes and file_attribute_directory) = 0 then str = " " end if do while findnextfile(hf, filedata) <> 0 strtmp = stripnulls(filedata.cfilename) if strtmp <> ". " and strtmp <> ".. " and (filedata.dwfileattributes and file_attribute_directory) then str = str & cns_filename_delimeter & strtmp end if loop elseif withdir = files_with_dir then ' including . and .. do while findnextfile(hf, filedata) <> 0 strtmp = stripnulls(filedata.cfilename) str = str & cns_filename_delimeter & strtmp loop elseif withdir = files_only_dir_including_dot then if str <> " " and (filedata.dwfileattributes and file_attribute_directory) = 0 then str = " " end if do while findnextfile(hf, filedata) <> 0 if (filedata.dwfileattributes and file_attribute_directory) then strtmp = stripnulls(filedata.cfilename) str = str & cns_filename_delimeter & strtmp end if loop end if findclose hf end if if mid(str, 1, 1) = cns_filename_delimeter then str = right(str, len(str) - 1) end if getfilesindir = str end function | | |
|