公司有一个用来根据物料编号,查询图片的的小程序,另外有一台图片服务器,通过程序显示对应的物料图片,现在对图片服务器中存储的图片文件夹进行了共享,并且设置了一个everyone都能读取的权限,这样,在程序运行的时候,就能顺利地读取到图片服务器中的图片,现在的问题是,我把图片文件夹设置为everyone都能读取的权限之后,公司內部所有的电脑(已经加域),都能访问.
领导的意思是,只有使用程序的用户才让他们能正常地读取图片,因为可能有很多域用户都会使用到程序,我也不可能把所有使用程序的域用户都一一地加到图片文件夹权限列表中来,不知道有沒有办法在程序中给域用户授与访问图片文件夹得读取权限?
总而言之,就是说所有运行查询图片程序的用户都可以访问图片文件夹,其他人只有通过我们的授权才能访问,everyone的权限感觉还是不安全,毕竟他们能读图片,那么就可以截图.
领导的意思是,只有使用程序的用户才让他们能正常地读取图片,因为可能有很多域用户都会使用到程序,我也不可能把所有使用程序的域用户都一一地加到图片文件夹权限列表中来,不知道有沒有办法在程序中给域用户授与访问图片文件夹得读取权限?
总而言之,就是说所有运行查询图片程序的用户都可以访问图片文件夹,其他人只有通过我们的授权才能访问,everyone的权限感觉还是不安全,毕竟他们能读图片,那么就可以截图.
把group加权限
可以把突破加到程序的resource里,执行时调用。
不过我想这些图片会有变化。
If Dir(gPhotoPath & IIf(stype = "", "", stype & "\") & sCusSerialNo & vItem & ".jpg") <> "" Then
imgPhoto.Picture = LoadPicture(gPhotoPath & IIf(stype = "", "", stype & "\") & sCusSerialNo & vItem & ".jpg")
Else
If Dir(gPhotoPath & sCusSerialNo & vItem & ".jpg") <> "" Then
imgPhoto.Picture = LoadPicture(gPhotoPath & sCusSerialNo & vItem & ".jpg")
Else
' If vItem <> "Temp" Then Set imgPhoto.Picture = LoadPicture(App.path & "\NoPic.jpg")
If Dir(gPhotoBPath & mSample & ".jpg") <> "" Then
imgPhoto.Picture = LoadPicture(gPhotoBPath & mSample & ".jpg")
Else
imgPhoto.Picture = LoadPicture(App.path & "\NoPic.jpg")
End If
End If
End If
Else
Set imgPhoto.Picture = Nothing
End If我想如果VB种有一种方法可以在访问磁盘文件的时候指定访问用户名和密码,那问题就解决了。
Private Const WTS_CURRENT_SERVER_HANDLE = 0&
Private Declare Function WTSQuerySessionInformationW Lib "wtsapi32" (ByVal hServer As Long, _
ByVal SessionID As Long, _
ByVal wtsInfoClass As Long, _
ByRef pBuffer As Long, _
ByRef pBytesReturned As Long _
) As Long
Private Enum wtsInfoClass
WTSInitialProgram
WTSApplicationName
WTSWorkingDirectory
WTSOEMId
WTSSessionId
WTSUserName
WTSWinStationName
WTSDomainName
WTSConnectState
WTSClientBuildNumber
WTSClientName
WTSClientDirectory
WTSClientProductId
WTSClientHardwareId
WtsClientAddress
WTSClientDisplay
WTSClientProtocolType
End Enum
Private Declare Sub WTSFreeMemory Lib "wtsapi32.dll" (ByVal pMemory As Long)
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal length As Long)
Private Declare Function GetCurrentProcessId Lib "Kernel32.dll" () As Long
Private Declare Sub ProcessIdToSessionId Lib "Kernel32.dll" (ByVal dwProcessId As Long, ByRef dwSectionId As Long)
Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long Private Function IsRemoteUser() As Boolean
Dim dwProcessId As Long
Dim dwSectionId As Long
Dim dwRet As Long
Dim nBytesReturned As Long
Dim pBuffer As Long
dwProcessId = GetCurrentProcessId
ProcessIdToSessionId dwProcessId, dwSectionId
dwRet = WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, dwSectionId, WTSClientName, pBuffer, nBytesReturned)
If dwRet <> 0 And nBytesReturned <> 0 And pBuffer <> 0 Then
IsRemoteUser = lstrlenW(pBuffer)
WTSFreeMemory pBuffer
End If
End Function
Private Sub Form_Load()
If IsRemoteUser Then '远程连接
blnRead=false
Else '本地连接
blnRead=true
End If
if blnRead=true then
'显示图片
endif
End Sub
18楼能判断是不是remote进来的,冒是偏题了。
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName As String * 128
End Type
Private Const OF_SHARE_DENY_READ = &H30
Dim Hfile As Long Dim my As OFSTRUCT
Private Sub Form_Load()
'禁止其他程序读写(包括执行)文件内容
Hfile = OpenFile("d:\foxmail.exe", my, OF_SHARE_DENY_READ)
End Sub Private Sub Form_Unload(Cancel As Integer)
Dim rlt As Long
'关闭文件句柄,撤消上面的禁止功能,可别忘了这一步哦:)
rlt = CloseHandle(Hfile) End Sub 解答(2):
open "test.dat" for binary lock read write as #1
~~~~~~~~~~~~~~~
..................
close #1
上面加~~的部分的意义:
share 其他进程可以共享读写此文件
lock read 其他进程只能读
lock write 其他进程只能写
lock read write 其他进程完全拒绝访问