我想在本地将一个文件夹共享给某个指定的用户,应该用哪些api处理(windows 2000中)?
例如:文件夹名C:\test,本机创建又一个用户名为pc01,在用api NetShareAdd()创建共享时,系统默认的用户是everyone,现在我要将everyone去掉然后改成pc01,要用哪些api函数?
(我现在要处理的程序是这样的。首先我要在服务器上创建很多用户,再对不同的用户创建和他们同名的文件夹,并且要将这些文件夹只能共享给对应用户)
这个问题province_(雍昊)和zcsor两位已经回复过,但是我还是不大明白.最好是有api的实例给出.
另:province_(雍昊)和zcsor分值已经送给你们了,请查收
例如:文件夹名C:\test,本机创建又一个用户名为pc01,在用api NetShareAdd()创建共享时,系统默认的用户是everyone,现在我要将everyone去掉然后改成pc01,要用哪些api函数?
(我现在要处理的程序是这样的。首先我要在服务器上创建很多用户,再对不同的用户创建和他们同名的文件夹,并且要将这些文件夹只能共享给对应用户)
这个问题province_(雍昊)和zcsor两位已经回复过,但是我还是不大明白.最好是有api的实例给出.
另:province_(雍昊)和zcsor分值已经送给你们了,请查收
解决方案 »
- vb6编了个代码,实现把vs2008源码,替换一下(部分文字).执行之后,中文全部变成乱码了,为什么?
- 如何改变游戏窗口的分辨率
- VB 定时运行程序
- [[[[[[ vsReport报表设计数据源的问题 ]]]]]]]]
- 大家帮帮我~~~·!!怎么做一个VB的射击游戏
- 如何复制局域网内某一机器的某一目录内的一个或多个文件
- vb+oracle8.0
- 请高手指教,为什么这段关于DBCombo的代码无作用
- 挑战高难度问题!急用,在线等,回复测试!
- 怎么用ShellExecute 调用,关闭文件及应用程序(例如WORD)!!!(空文档)
- 开源:穿越Socks5,Http1.1代理服务器的源程序
- 关于利用EXCEL打印VB报表(续)
'以下是对应我上次回贴的代码,思路是用PC01这个用户,去运行建立共享的程序(这个程序是你事先编译好的,用NetShareAdd创建共享的程序)
Option ExplicitPrivate Const LOGON_WITH_PROFILE = &H1&
Private Const CREATE_DEFAULT_ERROR_MODE = &H4000000
Private Const CREATE_NEW_CONSOLE = &H10&
Private Const CREATE_NEW_PROCESS_GROUP = &H200&Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End TypePrivate Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End TypePrivate Declare Function CreateProcessWithLogon Lib "advapi32" Alias "CreateProcessWithLogonW" (ByVal lpUsername As Long, ByVal lpDomain As Long, ByVal lpPassword As Long, ByVal dwLogonFlags As Long, ByVal lpApplicationName As Long, ByVal lpCommandLine As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInfo As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
'以下函数用制定名和密码调用了应用程序
Private Function AnShell(Username As String, Domain As String, Password As String, ApplicationName As String) As Long
Dim lpUsername As String, lpDomain As String, lpPassword As String, lpApplicationName As String, lpCommandLine As String, lpCurrentDirectory As String
Dim StartInfo As STARTUPINFO, ProcessInfo As PROCESS_INFORMATION
lpUsername = Username
lpDomain = Domain
lpPassword = Password
lpApplicationName = ApplicationName
lpCommandLine = vbNullString
lpCurrentDirectory = vbNullString
StartInfo.cb = LenB(StartInfo)
StartInfo.dwFlags = 0&
CreateProcessWithLogon StrPtr(lpUsername), StrPtr(lpDomain), StrPtr(lpPassword), LOGON_WITH_PROFILE, StrPtr(lpApplicationName), StrPtr(lpCommandLine), CREATE_DEFAULT_ERROR_MODE Or CREATE_NEW_CONSOLE Or CREATE_NEW_PROCESS_GROUP, ByVal 0&, StrPtr(lpCurrentDirectory), StartInfo, ProcessInfoCloseHandle ProcessInfo.hThread
CloseHandle ProcessInfo.hProcess
AnShell = ProcessInfo.dwProcessId
End Function
'注意:这里对于你的测试也许是不必要的,你只需要把PC02和他的密码在Form_Click事件中进行更改就可以了
Private Sub AddAdmin()
'建立PC02用户,这里密码设置成了PC02PASS
Shell "cmd.exe /c net user PC02 PC02PASS /add", vbHide'将这个用户权限提升为管理员Shell "cmd.exe /c net localgroup administrators PC02 /add", vbHideEnd SubPrivate Sub DelAdmin()
'删除建立的5个用户
Shell "cmd.exe /c net user PC02 /del", vbHideEnd SubPrivate Sub Form_Click()
'你需要将这里的字符串"PC02"换成你要访问共享的用户的名字,把"PC02PASS"换成其对应密码
'你需要将这里的NOTEPAD.EXE更改为你要调用共享的那个程序名
'用刚刚建立的管理员运行一个程序,这里是记事本,参数1为用户名,参数2为域(一般为空就可以了,因为是本机),参数3为要运行的程序路径和名字(这里调用的是WINDOWS下的程序,所以WINDOWS会自己找到的,程序运行时的几个PATH是WINDOWS,SYSTEM,SYSTEM32,APP.PATH,当然可以通过修改WINDOWS的PATH来改变)
AnShell "PC02", "", "PC02PASS", "notepad.exe"
'打开任务管理器,以便查看notepad.exe进程的所有者
Shell "taskmgr.exe"
End SubPrivate Sub Form_Load()
'建立一个用户并提升权限为管理员
AddAdmin
End SubPrivate Sub Form_Unload(Cancel As Integer)
'删除调试时建立的管理员
DelAdmin
End Sub
这个用上面的代码就可以了然后ntfs权限
先放两个command和两个text
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' API calls used within this sample. Refer to the MSDN for more
' information on how/what these APIs do.Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function LookupAccountName Lib "advapi32.dll" Alias "LookupAccountNameA" (lpSystemName As String, ByVal lpAccountName As String, sid As Any, cbSid As Long, ByVal ReferencedDomainName As String, cbReferencedDomainName As Long, peUse As Long) As Long
Declare Function InitializeSecurityDescriptor Lib "advapi32.dll" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal dwRevision As Long) As Long
Declare Function GetSecurityDescriptorDacl Lib "advapi32.dll" (pSecurityDescriptor As Byte, lpbDaclPresent As Long, pDacl As Long, lpbDaclDefaulted As Long) As Long
Declare Function GetFileSecurityN Lib "advapi32.dll" Alias "GetFileSecurityA" (ByVal lpFileName As String, ByVal RequestedInformation As Long, ByVal pSecurityDescriptor As Long, ByVal nLength As Long, lpnLengthNeeded As Long) As Long
Declare Function GetFileSecurity Lib "advapi32.dll" Alias "GetFileSecurityA" (ByVal lpFileName As String, ByVal RequestedInformation As Long, pSecurityDescriptor As Byte, ByVal nLength As Long, lpnLengthNeeded As Long) As Long
Declare Function GetAclInformation Lib "advapi32.dll" (ByVal pAcl As Long, pAclInformation As Any, ByVal nAclInformationLength As Long, ByVal dwAclInformationClass As Long) As Long
Public Declare Function EqualSid Lib "advapi32.dll" (pSid1 As Byte, ByVal pSid2 As Long) As Long
Declare Function GetLengthSid Lib "advapi32.dll" (pSid As Any) As Long
Declare Function InitializeAcl Lib "advapi32.dll" (pAcl As Byte, ByVal nAclLength As Long, ByVal dwAclRevision As Long) As Long
Declare Function GetAce Lib "advapi32.dll" (ByVal pAcl As Long, ByVal dwAceIndex As Long, pace As Any) As Long
Declare Function AddAce Lib "advapi32.dll" (ByVal pAcl As Long, ByVal dwAceRevision As Long, ByVal dwStartingAceIndex As Long, ByVal pAceList As Long, ByVal nAceListLength As Long) As Long
Declare Function AddAccessAllowedAce Lib "advapi32.dll" (pAcl As Byte, ByVal dwAceRevision As Long, ByVal AccessMask As Long, pSid As Byte) As Long
Public Declare Function AddAccessDeniedAce Lib "advapi32.dll" (pAcl As Byte, ByVal dwAceRevision As Long, ByVal AccessMask As Long, pSid As Byte) As Long
Declare Function SetSecurityDescriptorDacl Lib "advapi32.dll" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal bDaclPresent As Long, pDacl As Byte, ByVal bDaclDefaulted As Long) As Long
Declare Function SetFileSecurity Lib "advapi32.dll" Alias "SetFileSecurityA" (ByVal lpFileName As String, ByVal SecurityInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Public Sub SetAccess(sUserName As String, sFileName As String, lMask As Long)
Dim lResult As Long ' Result of various API calls.
Dim I As Integer ' Used in looping.
Dim bUserSid(255) As Byte ' This will contain your SID.
Dim bTempSid(255) As Byte ' This will contain the Sid of each ACE in the ACL .
Dim sSystemName As String ' Name of this computer system. Dim lSystemNameLength As Long ' Length of string that contains
' the name of this system. Dim lLengthUserName As Long ' Max length of user name. 'Dim sUserName As String * 255 ' String to hold the current user
' name.
' current user. Dim lTempSid As Long ' Used to hold the SID of each ACE in the ACL
Dim lUserSIDSize As Long ' Size of the SID.
Dim sDomainName As String * 255 ' Domain the user belongs to.
Dim lDomainNameLength As Long ' Length of domain name needed. Dim lSIDType As Long ' The type of SID info we are
' getting back. Dim sFileSD As SECURITY_DESCRIPTOR ' SD of the file we want. Dim bSDBuf() As Byte ' Buffer that holds the security
' descriptor for this file. Dim lFileSDSize As Long ' Size of the File SD.
Dim lSizeNeeded As Long ' Size needed for SD for file.
Dim sNewSD As SECURITY_DESCRIPTOR ' New security descriptor. Dim sACL As ACL ' Used in grabbing the DACL from
' the File SD. Dim lDaclPresent As Long ' Used in grabbing the DACL from
' the File SD. Dim lDaclDefaulted As Long ' Used in grabbing the DACL from
' the File SD. Dim sACLInfo As ACL_SIZE_INFORMATION ' Used in grabbing the ACL
' from the File SD. Dim lACLSize As Long ' Size of the ACL structure used
' to get the ACL from the File SD. Dim pAcl As Long ' Current ACL for this file.
Dim lNewACLSize As Long ' Size of new ACL to create.
Dim bNewACL() As Byte ' Buffer to hold new ACL. Dim sCurrentACE As ACCESS_ALLOWED_ACE ' Current ACE.
Dim pCurrentAce As Long ' Our current ACE. Dim nRecordNumber As Long ' Get the SID of the user. (Refer to the MSDN for more information on SIDs
' and their function/purpose in the operating system.) Get the SID of this
' user by using the LookupAccountName API. In order to use the SID
' of the current user account, call the LookupAccountName API
' twice. The first time is to get the required sizes of the SID
' and the DomainName string. The second call is to actually get
' the desired information. lResult = LookupAccountName(vbNullString, sUserName, _
bUserSid(0), 255, sDomainName, lDomainNameLength, _
lSIDType) ' Now set the sDomainName string buffer to its proper size before
' calling the API again.
sDomainName = Space(lDomainNameLength) ' Call the LookupAccountName again to get the actual SID for user.
lResult = LookupAccountName(vbNullString, sUserName, _
bUserSid(0), 255, sDomainName, lDomainNameLength, _
lSIDType) ' Return value of zero means the call to LookupAccountName failed;
' test for this before you continue.
If (lResult = 0) Then
MsgBox "Error: Unable to Lookup the Current User Account: " _
& sUserName
Exit Sub
End If ' You now have the SID for the user who is logged on.
' The SID is of interest since it will get the security descriptor
' for the file that the user is interested in.
' The GetFileSecurity API will retrieve the Security Descriptor
' for the file. However, you must call this API twice: once to get
' the proper size for the Security Descriptor and once to get the
' actual Security Descriptor information. lResult = GetFileSecurityN(sFileName, DACL_SECURITY_INFORMATION, _
0, 0, lSizeNeeded) ' Redimension the Security Descriptor buffer to the proper size.
ReDim bSDBuf(lSizeNeeded) ' Now get the actual Security Descriptor for the file.
lResult = GetFileSecurity(sFileName, DACL_SECURITY_INFORMATION, _
bSDBuf(0), lSizeNeeded, lSizeNeeded) ' A return code of zero means the call failed; test for this
' before continuing.
If (lResult = 0) Then
MsgBox "Error: Unable to Get the File Security Descriptor"
Exit Sub
End If ' Call InitializeSecurityDescriptor to build a new SD for the
' file.
lResult = InitializeSecurityDescriptor(sNewSD, _
SECURITY_DESCRIPTOR_REVISION) ' A return code of zero means the call failed; test for this
' before continuing.
If (lResult = 0) Then
MsgBox "Error: Unable to Initialize New Security Descriptor"
Exit Sub
End If ' You now have the file's SD and a new Security Descriptor
' that will replace the current one. Next, pull the DACL from
' the SD. To do so, call the GetSecurityDescriptorDacl API
' function. lResult = GetSecurityDescriptorDacl(bSDBuf(0), lDaclPresent, _
pAcl, lDaclDefaulted) ' A return code of zero means the call failed; test for this
' before continuing.
If (lResult = 0) Then
MsgBox "Error: Unable to Get DACL from File Security " _
& "Descriptor"
Exit Sub
End If ' You have the file's SD, and want to now pull the ACL from the
' SD. To do so, call the GetACLInformation API function.
' See if ACL exists for this file before getting the ACL
' information.
If (lDaclPresent = False) Then
MsgBox "Error: No ACL Information Available for this File"
Exit Sub
End If
lResult = GetAclInformation(pAcl, sACLInfo, Len(sACLInfo), 2&) ' A return code of zero means the call failed; test for this
' before continuing.
If (lResult = 0) Then
MsgBox "Error: Unable to Get ACL from File Security Descriptor"
Exit Sub
End If ' Now that you have the ACL information, compute the new ACL size
' requirements.
lNewACLSize = sACLInfo.AclBytesInUse + (Len(sCurrentACE) + _
GetLengthSid(bUserSid(0))) * 2 - 4 ' Resize our new ACL buffer to its proper size.
ReDim bNewACL(lNewACLSize) ' Use the InitializeAcl API function call to initialize the new
' ACL.
lResult = InitializeAcl(bNewACL(0), lNewACLSize, ACL_REVISION) ' A return code of zero means the call failed; test for this
' before continuing.
If (lResult = 0) Then
MsgBox "Error: Unable to Initialize New ACL"
Exit Sub
End If ' If a DACL is present, copy it to a new DACL.
If (lDaclPresent) Then ' Copy the ACEs from the file to the new ACL.
If (sACLInfo.AceCount > 0) Then ' Grab each ACE and stuff them into the new ACL.
nRecordNumber = 0
For I = 0 To (sACLInfo.AceCount - 1) ' Attempt to grab the next ACE.
lResult = GetAce(pAcl, I, pCurrentAce) ' Make sure you have the current ACE under question.
If (lResult = 0) Then
MsgBox "Error: Unable to Obtain ACE (" & I & ")"
Exit Sub
End If ' You have a pointer to the ACE. Place it
' into a structure, so you can get at its size.
CopyMemory sCurrentACE, pCurrentAce, LenB(sCurrentACE) 'Skip adding the ACE to the ACL if this is same usersid
lTempSid = pCurrentAce + 8
If EqualSid(bUserSid(0), lTempSid) = 0 Then ' Now that you have the ACE, add it to the new ACL.
lResult = AddAce(VarPtr(bNewACL(0)), ACL_REVISION, _
MAXDWORD, pCurrentAce, _
sCurrentACE.Header.AceSize) ' Make sure you have the current ACE under question.
If (lResult = 0) Then
MsgBox "Error: Unable to Add ACE to New ACL"
Exit Sub
End If
nRecordNumber = nRecordNumber + 1
End If Next I ' You have now rebuilt a new ACL and want to add it to
' the newly created DACL.
lResult = AddAccessAllowedAce(bNewACL(0), ACL_REVISION, _
lMask, bUserSid(0)) ' Make sure added the ACL to the DACL.
If (lResult = 0) Then
MsgBox "Error: Unable to Add ACL to DACL"
Exit Sub
End If 'If it's directory, we need to add inheritance staff.
If GetAttr(sFileName) And vbDirectory Then ' Attempt to grab the next ACE which is what we just added.
lResult = GetAce(VarPtr(bNewACL(0)), nRecordNumber, pCurrentAce) ' Make sure you have the current ACE under question.
If (lResult = 0) Then
MsgBox "Error: Unable to Obtain ACE (" & I & ")"
Exit Sub
End If
' You have a pointer to the ACE. Place it
' into a structure, so you can get at its size.
CopyMemory sCurrentACE, pCurrentAce, LenB(sCurrentACE)
sCurrentACE.Header.AceFlags = OBJECT_INHERIT_ACE + INHERIT_ONLY_ACE
CopyMemory ByVal pCurrentAce, VarPtr(sCurrentACE), LenB(sCurrentACE) 'add another ACE for files
lResult = AddAccessAllowedAce(bNewACL(0), ACL_REVISION, _
lMask, bUserSid(0)) ' Make sure added the ACL to the DACL.
If (lResult = 0) Then
MsgBox "Error: Unable to Add ACL to DACL"
Exit Sub
End If ' Attempt to grab the next ACE.
lResult = GetAce(VarPtr(bNewACL(0)), nRecordNumber + 1, pCurrentAce) ' Make sure you have the current ACE under question.
If (lResult = 0) Then
MsgBox "Error: Unable to Obtain ACE (" & I & ")"
Exit Sub
End If CopyMemory sCurrentACE, pCurrentAce, LenB(sCurrentACE)
sCurrentACE.Header.AceFlags = CONTAINER_INHERIT_ACE
CopyMemory ByVal pCurrentAce, VarPtr(sCurrentACE), LenB(sCurrentACE)
End If
' Set the file's Security Descriptor to the new DACL.
lResult = SetSecurityDescriptorDacl(sNewSD, 1, _
bNewACL(0), 0) ' Make sure you set the SD to the new DACL.
If (lResult = 0) Then
MsgBox "Error: " & _
"Unable to Set New DACL to Security Descriptor"
Exit Sub
End If ' The final step is to add the Security Descriptor back to
' the file!
lResult = SetFileSecurity(sFileName, _
DACL_SECURITY_INFORMATION, sNewSD) ' Make sure you added the Security Descriptor to the file!
If (lResult = 0) Then
MsgBox "Error: Unable to Set New Security Descriptor " _
& " to File : " & sFileName
MsgBox Err.LastDllError
Else
MsgBox "Updated Security Descriptor on File: " _
& sFileName
End If End If End IfEnd Sub把后面的代码放在模块里
这样就ok了
使文件夹专用
打开 我的电脑。
双击安装 Windows 的驱动器(通常为驱动器 C,除非计算机上有多个驱动器)。
如果该驱动器的内容是隐藏的,可以在“系统任务”下,单击“显示此驱动器的内容”。双击“Documents and Settings”文件夹。
双击用户文件夹。
右键单击用户配置文件中的任意文件夹,然后单击“属性”。
在“共享”选项卡上,选择“将这个文件夹设为个人的,这样只有我才能访问”复选框。
注意要打开“我的电脑”,请单击“开始”,然后单击“我的电脑”。
该选项仅可用于包含在用户配置文件中的文件夹。用户配置文件中的文件夹包括了“我的文档”及其子文件夹、桌面、“开始”菜单、Cookies 和收藏夹。如果没有使这些文件夹专用,则任何使用该计算机的人都可使用这些文件夹。
当使一个文件夹专用时,则该文件夹中的所有子文件夹也是专用的。例如,如果使“我的文档”专用,则也会使“我的音乐”和“图片收藏”专用。共享一个文件夹时,其子文件夹也是共享的,除非您使它们专用。
如果驱动器未格式化为 NTFS 格式,则不能使文件夹专用。有关将驱动器转换为 NTFS 格式的详细信息,请单击“相关主题”。 设置、查看、更改或删除文件和文件夹权限
打开 Windows 资源管理器,然后定位到您要设置权限的文件和文件夹。
右键单击该文件或文件夹,单击“属性”,然后单击“安全”选项卡。
执行下列操作之一:
要为没有出现于“组或用户名称”框中的组或用户设置权限,请单击“添加”。键入想要为其设置权限的组或用户的名称,然后单击“确定”。
要更改或删除现有的组或用户的权限,请单击该组或用户的名称。
执行下列操作之一:
要允许或拒绝某一权限,请在“用户或者组的权限”框中,选中“允许”或“拒绝”复选框。
要从“组或用户名称”框中删除组或者用户,请单击“删除”。
要点如果您没有加入域并想查看“安全”选项卡,参见显示“安全”选项卡。
注意要打开“Windows 资源管理器”,请单击“开始”,依次指向“所有程序”、“附件”,然后单击“Windows 资源管理器”。
在 Windows XP Professional 中,Everyone 组不再包括 Anonymous Logon。
只能在格式化为使用 NTFS 的驱动器上设置文件和文件夹权限。
要更改访问权限,您必须是所有者或已经由所有者授权执行该操作。
无论保护文件和子文件夹的权限如何,被准许对文件夹进行完全控制的组或用户都可以删除该文件夹内的任何文件和子文件夹。
如果“用户或组的权限”下的复选框为灰色,或者“删除”按钮不可用,则文件或文件夹已经继承了父文件夹的权限。有关继承如何影响文件和文件夹的详细信息,请参阅相关主题。
添加一个新用户和新组,默认情况下该用户或组具有“读取和执行”、“列出文件夹内容”和“读取”权限。
有关其他对象权限的详细信息,请参阅权限。
2、用下面这个函数看看shi2_current_uses到底描述了什么,也许是指定用户呢。。呵呵
Private Declare Function NetShareEnum Lib _
"netapi32.dll" (ServerName As Byte, ByVal _
level As Long, Buffer As Long, ByVal _
PreMaxLen As Long, EntriesRead As Long, _
TotalEntries As Long, Resume_Handle As Long) _
As Long
关注。。关注等待学习
我运行你给的程序,但是运行到
' Attempt to get the ACL from the file's Security Descriptor.
lResult = GetAclInformation(pAcl, sACLInfo, Len(sACLInfo), 2&)
就崩溃掉了,还有我发现 Public Const GENERIC_READ = &H80000000 运行的时候是负数,怎么回事啊
这个是16进制常数你去api查一下这个常数的值你就知道了而且我运行没有任何问题不知道你机器是什么问题首先你要有这个用户其次你要有这个目录text1是目录 名 text2是用户名
我知道Public Const GENERIC_READ = &H80000000 是十六进制常数,但是我在调试时候我发 现他变成了 -2XXXXXXXXX,X代表数字。我用的是win2000的 FAT32 格式,不知道是不是这个原因。我用的是带了路径的目录名。您有没有QQ,我想向您当面请教一下,我的QQ是 9011430
我开始以为是操作系统的问题(我的是win2k profession),后来我用win2k server(FAT32) 版测试也还是在那个地方崩溃掉找不到原因,急啊!我用的是vb6
你用fat32怎么行这个是ntfs格式的pession阿