Tải bản đầy đủ (.pdf) (7 trang)

AutoI Technology Curriculum Book part 27 ppsx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (79.4 KB, 7 trang )


Function Reference
FileGetAttrib
trả lại chuỗi kí tự mang thuộc tính của file.
FileGetAttrib ( "filename" )
Parameters
filename đường dẫn tới file hoặc thư mục

Return Value
Success:

trả lại 1 chuỗi gồm các thuộc tính của file (xem bên dưới)
Failure:

trả "" (chuỗi rỗng) và set @error = 1.

Remarks
chuỗi trả lại là sự kết hợp của các kí tự sau, vd "RA" là readonly và archive
"R" = READONLY
"A" = ARCHIVE
"S" = SYSTEM
"H" = HIDDEN
"N" = NORMAL
"D" = DIRECTORY
"O" = OFFLINE
"C" = COMPRESSED (nén kiểu NTFS , ko phải kiểu nén ZIP)
"T" = TEMPORARY
Related
FileGetTime, FileSetAttrib
Example


$attrib = FileGetAttrib("c:\boot.ini")
If @error Then
MsgBox(4096,"Error", "Could not obtain attributes.")
Exit
Else
If StringInStr($attrib, "R") Then
MsgBox(4096,"", "File is read-only.")
EndIf
EndIf

; Display full attribute information in text form
; Arrays rely upon the fact that each capital letter is unique
; Figuring out how this works is a good string exercise
$input = StringSplit("R,A,S,H,N,D,O,C,T",",")
$output = StringSplit("Read-only /, Archive /, System /, Hidden /" & _
", Normal /, Directory /, Offline /, Compressed /, Temporary /", ",")
For $i = 1 to 9
$attrib = StringReplace($attrib, $input[$i], $output[$i], 0, 1)
; last parameter in StringReplace means case-sensitivity
Next
$attrib = StringTrimRight($attrib, 2) ;remove trailing slash
MsgBox(0,"Full file attributes:", $attrib)




Function Reference
FileGetLongName
trả lại tên "dài"
FileGetLongName ( "file" [, flag] )

Parameters
file đường dẫn tới file cần chuyển đổi
flag nếu là 1 thì tệp tin ko cần chỉ rod đường dẫn vd e.g. " \file.txt"

Return Value
Success:

trả lại chuỗi kí tự
Failure:

trả lại tham số và sets @error = 1.

Remarks
None.
Related
FileGetShortName
Example

$a = FileGetLongName(@HomeDrive & "\PROGRA~1\")
msgbox(0,"long file name", $a)
;$a is probably "x:\Program Files"




Function Reference
FileGetShortcut
trả lại thông tin chi tiết của shortcut
FileGetShortcut ( "lnk" )
Parameters

lnk đường dẫn tới shortcut cần biết chi tiết

Return Value
Success:

trả lại một mảng gồm 7 thông tin xem ở dưới
Failure:

Sets @error = 1 nếu shortcut ko thể truy cập hoặc ko tồn tại

Remarks
mảng trả lại gồm 7 phần tử chứa các thông tin sau
$array[0] = đường dẫn tới file mà shortcut dẫn tới
$array[1] = thư mục làm việc
$array[2] = Arguments
$array[3] = Description
$array[4] = tên file Icon
$array[5] = số thứ tự Icon
$array[6] = kiểu chạy (@SW_SHOWNORMAL, @SW_SHOWMINNOACTIVE,
@SW_SHOWMAXIMIZED)
Related
FileCreateShortcut
Example

; Sets a shortcut with ctrl+alt+t hotkey
FileCreateShortcut(@WindowsDir & "\Explorer.exe",@DesktopDir & "\Shortcut
Test.lnk",@WindowsDir,"/e,c:\", "This is an Explorer link;-)", @SystemDir &
"\shell32.dll", "^!t", "15", @SW_MINIMIZE)

; Read in the path of a shortcut

$details = FileGetShortcut(@DesktopDir & "\Shortcut Test.lnk")
MsgBox(0, "Path:", $details[0])




Function Reference
FileGetShortName
trả lại tên gắn gọn của file (8 kí tự cho tên, 3 kí tự cho phần mở rộng)
FileGetShortName ( "file" [, flag] )
Parameters
file đường dẫn tới file cần chuyển đổi
flag nếu là 1 thì tệp tin ko cần chỉ rod đường dẫn vd e.g. " \file.txt"

Return Value
Success:

trả lại chuỗi kí tự
Failure:

trả lại tham số và sets @error = 1.

Remarks
Các tập tin cần phải tồn tại như không có cách nào để biết chính xác ~ i, nếu một
số tập tin có cùng một ký tự đầu tiên 8.
Related
FileGetLongName
Example

$a = FileGetShortName(@HomeDrive & "\Program Files")

msgbox(0,"long file name", $a)
;$a is probably "x:\PROGRA~1"




Function Reference
FileGetSize
trả lại dung lượng của file (tính = byte)
FileGetSize ( "filename" )
Parameters
filename đường dẫn tới file yêu cầu

Return Value
Success:

trsr lại số > 0
Failure:

trả lại 0 và set @error = 1

Remarks
hàm ko làm việc với thư mục
chia cho 1024 để đc kb, chia 1048576 để đc mb


Related
FileGetAttrib, FileGetTime, DriveSpaceTotal
Example


×