主题:VB在任何系统C盘下建立夹和文件
yzai
[专家分:20] 发布于 2009-09-14 21:59:00
Private Sub Command1_Click()
On Error Resume Next
Dim Buffer As String
Buffer = Space(MAX_PATH)
rtn = GetWindowsDirectory(Buffer, Len(Buffer))
WinPath = Left(Buffer, rtn)
Dim UserInput
UserInput = "1"
MkDir WinPath & "\" & UserInput
按下COMMAND1按钮时就建立一个文件夹,然后根据文件夹的路径保存SHELL.DRV这个文件请问怎么做``
Open MkDir WinPath & "\1\SHELL.DRV" For Output As #5 关键在这里吗?
'Open "MkDir WinPath & " \ " & UserInput & " \ " & SHELL.DRV" For Output As #5
Print #5, text1.Text
Close #5
我想了好久都想不出来`请大家帮忙解决`谢谢
End Sub
回复列表 (共8个回复)
沙发
wwc7654321 [专家分:1590] 发布于 2009-09-14 22:31:00
[quote]
Open MkDir WinPath & "\1\SHELL.DRV" For Output As #5
'Open "MkDir WinPath & " \ " & UserInput & " \ " & SHELL.DRV" For Output As #5
[/quote]
MkDir是没有返回值的也别加到地址中去 否则访问的是 "MkDir c:\windows\1\shell.drv"
且地址中没有不必要的空格
Open WinPath & "\" & UserInput & "\" & "SHELL.DRV" For Output As #5
板凳
一江秋水 [专家分:9680] 发布于 2009-09-16 11:47:00
可以使用Folder对象的CreateFolder方法创建一个文件夹,非常简单,有了文件夹后,保存文件就更加
简单了。
3 楼
yzai [专家分:20] 发布于 2009-09-16 21:52:00
[quote]可以使用Folder对象的CreateFolder方法创建一个文件夹,非常简单,有了文件夹后,保存文件就更加
简单了。
[/quote]
可以给出代码么?
4 楼
天天学习 [专家分:4570] 发布于 2009-09-16 23:07:00
API:SHCreateDirectoryEx
http://bbs.pfan.cn/post-308381.html
5 楼
一江秋水 [专家分:9680] 发布于 2009-09-17 09:06:00
Private Sub Command1_Click()
Dim objdir
Dim anewfolder As String
Set objdir = CreateObject("scripting.filesystemobject")
anewfolder = "d:\新建文件夹"
objdir.createfolder (anewfolder)
Set objdir = Nothing
End Sub
6 楼
yzai [专家分:20] 发布于 2009-09-20 23:48:00
[quote][quote]
Open MkDir WinPath & "\1\SHELL.DRV" For Output As #5
'Open "MkDir WinPath & " \ " & UserInput & " \ " & SHELL.DRV" For Output As #5
[/quote]
MkDir是没有返回值的也别加到地址中去 否则访问的是 "MkDir c:\windows\1\shell.drv"
且地址中没有不必要的空格
Open WinPath & "\" & UserInput & "\" & "SHELL.DRV" For Output As #5
[/quote]
Private Sub Command1_Click()
Shell "regsvr32 SHELL.DRV" /s
那请问这段代码又改怎么加啊?
是这样嘛 Shell regsvr32 & WinPath & "\" & UserInput & "\" & "SHELL.DRV" /s
End Sub
7 楼
yzai [专家分:20] 发布于 2009-09-29 20:27:00
Private Sub Command1_Click()
Shell "regsvr32 SHELL.DRV" /s
那请问这段代码又改怎么加啊?
是这样嘛 Shell regsvr32 & WinPath & "\" & UserInput & "\" & "SHELL.DRV" /s
End Sub
8 楼
wwc7654321 [专家分:1590] 发布于 2009-10-01 13:29:00
Shell "regsvr32 "&chr(34) & WinPath & "\" & UserInput & "\" & "SHELL.DRV"& chr(34) &" /s"
我来回复