如题!!
解决方案 »
- 关于JPG图片旋转问题,急急急!!!
- Windows 2000 Professional 下安装SQL2000的问题!
- 如何获取窗体菜单的坐标???请进
- 一条查询语句,在SQL没事,在Access中老是出错
- 请有CODE的朋友帮个忙!
- 关于VB连接水晶报表的两个问题。急!
- vb6编译器如何启动时就自动所有窗口(窗体/代码)都默认最大化?每次打开编译器代码窗口都是缩着的,还得手弄一下,蛋疼得紧
- 大家能不能帮我解决这样的问题?
- 怎么关于多线程的贴子都不能显示?在vb里都有哪些方法可以实现多线程,各有何利弊?
- 好的想法,没好的思路
- 关于trim函数的简单问题,高手不要笑我
- 怎么在安装做好的软件时传入数据并使用
Private Declare Function SetFileSecurity Lib "advapi32.dll" Alias "SetFileSecurityA" (ByVal lpFileName As String, ByVal SecurityInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR) As Long【别名】
SetFileSecurityA
http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/711/qid/460090
'2. Add two Textboxes (Text1 and Text2) and two CommandButtons (Command1 and Command2) to Form1.
'3. Add the following code to the form and the module
'4. Run the application.
'5. In the Test1 TextBox, enter the name of the folder you want to change permissions on. (D:\test is entered by default.)
' In the Test2 Textbox, enter the name of the user you want to give these permissions to.
'6. Click the Add & Read permissions button to give Add & Read permissions to the folder, or click the Change Permissions
' button to give Change permissions to the folder.
'7. To check the permissions on the folder, right-click Explorer. Select the Properties menu item, and click the Security
' Tab of the Properties dialog box. On the Security tab, click the Permissions button. The specific account should say
' Add & Read or Change depending on which button you clicked in the preceding sample.'Add this code to the form
Private Sub Command1_Click()
Dim sUserName As String
Dim sFolderName As String
sUserName = Trim$(CStr(Text2.Text))
sFolderName = Trim$(CStr(Text1.Text))
SetAccess sUserName, sFolderName, GENERIC_READ Or GENERIC_EXECUTE Or DELETE Or GENERIC_WRITE
End Sub
Private Sub Command2_Click()
Dim sUserName As String
Dim sFolderName As String
sUserName = Trim$(Text2.Text)
sFolderName = Trim$(Text1.Text)
SetAccess sUserName, sFolderName, GENERIC_EXECUTE Or GENERIC_READ
End Sub
Private Sub Form_Load()
Text1.Text = "enter folder name"
Text2.Text = "enter username"
Command1.Caption = "Change"
Command2.Caption = "Read && Add"
End Sub'Add this code to a module' Constants used within our API calls. Refer to the MSDN for more
' information on how/what these constants are used for.' Memory constants used through various memory API calls.
Public Const GMEM_MOVEABLE = &H2
Public Const LMEM_FIXED = &H0
Public Const LMEM_ZEROINIT = &H40
Public Const LPTR = (LMEM_FIXED + LMEM_ZEROINIT)
Public Const GENERIC_READ = &H80000000
Public Const GENERIC_ALL = &H10000000
Public Const GENERIC_EXECUTE = &H20000000
Public Const GENERIC_WRITE = &H40000000' The file/security API call constants.
' Refer to the MSDN for more information on how/what these constants
' are used for.
Public Const DACL_SECURITY_INFORMATION = &H4
Public Const SECURITY_DESCRIPTOR_REVISION = 1
Public Const SECURITY_DESCRIPTOR_MIN_LENGTH = 20
Public Const SD_SIZE = (65536 + SECURITY_DESCRIPTOR_MIN_LENGTH)
Public Const ACL_REVISION2 = 2
Public Const ACL_REVISION = 2
Public Const MAXDWORD = &HFFFFFFFF
Public Const SidTypeUser = 1
Public Const AclSizeInformation = 2' The following are the inherit flags that go into the AceFlags field
' of an Ace header.Public Const OBJECT_INHERIT_ACE = &H1
Public Const CONTAINER_INHERIT_ACE = &H2
Public Const NO_PROPAGATE_INHERIT_ACE = &H4
Public Const INHERIT_ONLY_ACE = &H8
Public Const INHERITED_ACE = &H10
Public Const VALID_INHERIT_FLAGS = &H1F
Public Const DELETE = &H10000' Structures used by our API calls.
' Refer to the MSDN for more information on how/what these
' structures are used for.
Type ACE_HEADER
AceType As Byte
AceFlags As Byte
AceSize As Integer
End Type
Public Type ACCESS_DENIED_ACE
Header As ACE_HEADER
Mask As Long
SidStart As Long
End TypeType ACCESS_ALLOWED_ACE
Header As ACE_HEADER
Mask As Long
SidStart As Long
End TypeType ACL
AclRevision As Byte
Sbz1 As Byte
AclSize As Integer
AceCount As Integer
Sbz2 As Integer
End TypeType ACL_SIZE_INFORMATION
AceCount As Long
AclBytesInUse As Long
AclBytesFree As Long
End TypeType SECURITY_DESCRIPTOR
Revision As Byte
Sbz1 As Byte
Control As Long
Owner As Long
Group As Long
sACL As ACL
Dacl As ACL
End Type