vb中的filecopy 遇到拒绝权限如何解决
答案:3 悬赏:60 手机版
解决时间 2021-03-25 07:04
- 提问者网友:遁入空寂
- 2021-03-24 12:04
vb中的filecopy 遇到拒绝权限如何解决
最佳答案
- 五星知识达人网友:摆渡翁
- 2021-03-24 12:48
你是不是要将文件复制到你的系统盘中时遇到拒绝权限,如果是的话可以使用以下代码解决(对windows vista和win7 操作系统一定有效,对windows xp 我就不知道了):
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Private Sub Form_Click()
s = ShellExecute(0&, "runas", "程序名称", vbNullString, vbNullString, SW_SHOW)
End Sub
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Private Sub Form_Click()
s = ShellExecute(0&, "runas", "程序名称", vbNullString, vbNullString, SW_SHOW)
End Sub
全部回答
- 1楼网友:独钓一江月
- 2021-03-24 15:10
不懂你说的,管理员权限?
- 2楼网友:掌灯师
- 2021-03-24 14:27
这一般是文件被别的应用程序打开时而出现的情况
一、试试API函数CopyFile
二、自己编写个共享复制函数,示例如下:
Public Function FileCopyEx(ByVal SouFileName As String, ByVal DestFileName As String)
'复制文件,可以复制正在使用的文件.
'SouFileName - 源文件
'DestFileName - 目标文件
Dim tmpArr() As Byte
Open SouFileName For Binary Access Read As #1
ReDim tmpArr(LOF(1))
Get 1, , tmpArr
Close #1
Open DestFileName For Binary As #2
Put 2, , tmpArr
Close #2
ReDim tmpArr(0) '释放内存
End Function
一、试试API函数CopyFile
二、自己编写个共享复制函数,示例如下:
Public Function FileCopyEx(ByVal SouFileName As String, ByVal DestFileName As String)
'复制文件,可以复制正在使用的文件.
'SouFileName - 源文件
'DestFileName - 目标文件
Dim tmpArr() As Byte
Open SouFileName For Binary Access Read As #1
ReDim tmpArr(LOF(1))
Get 1, , tmpArr
Close #1
Open DestFileName For Binary As #2
Put 2, , tmpArr
Close #2
ReDim tmpArr(0) '释放内存
End Function
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯