>>  Site Map >>  Forums >>  Programers World

Forum module - topics in forum:



Programers World - mã nguồn chương trình, các công cụ lập trình, biên dịch, mã hóa, giải mã..



Hàm API tạo thư mục

Chúng ta sẽ sử dụng hàm API này để tạo một thư mục mới trên ổ đĩa.
Đó là hàm CreateDirectory, khai báo hàm này như sau trong VB

Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

Hàm này sử dụng biến lpSecurityAttributes để tạo bảo mật cho thư mục, nó chỉ có ý nghĩa khi thực hiện trên Windows NT, Windows 2000 hoặc cao hơn.
Cấu trúc dữ liệu đó khai báo như sau:

Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Ta viết mã như sau: (B3)

Sub CreateFolder
Dim lpSecurity As SECURITY_ATTRIBUTES

lpSecurity.bInheritHandle = 0
lpSecurity.lpSecurityDescriptor = 0
lpSecurity.nLength = 0
CreateDirectory "c:\vidu1", lpSecurity

End Sub




Search from ALEXA


put your ads here