怎么做安装程序能copy文件的安装程序

abianyu 2001-12-06 06:18:08
我做的程序需要copy一个数据库到安装目录下,可是vb的安装程序不能这么做
各位大虾有什么好方法吗,另外怎么在指定的目录创建一个目录并把一些文件
copy到这里去
...全文
90 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
DeityFox 2001-12-06
  • 打赏
  • 举报
回复
一个简单的安装程序
Public Jimbo As Integer
Public ProgramName As String

Private Sub form_load()
LblMain.Caption = "This program will install the files needed on your computer to run your application. Click next to continue..."
Command1.Caption = "Next..."
Me.Caption = "Setup..."
End Sub
Private Sub Command1_Click()
ProgramName = "Program Name"
If Jimbo = 3 Then
Unload Me: End
Else
Jimbo = Jimbo + 1
Select Case Jimbo
Case 1
LblMain.Caption = "This Setup will install " & ProgramName & ".exe and other components. Please click next to continue."
Case 2
Make_Directories
LblMain.Caption = "Click Next to copy the files into the directory 'C:\WillowSeven'"
Copy_Files
EditReg
Case 3
LblMain.Caption = "Setup Complete!": MsgBox "Complete!", , "": Command1.Caption = "Done"
End Select
End If
End Sub
Private Sub EditReg()
'This inserts files into the registry. e.g.
End Sub
Private Sub Copy_Files()
'This is where you put all the file copying Material
ChDir App.Path
FileCopy App.EXEName & ".exe", "C:\Willow seven\Program\" & ProgramName & ".exe"
End Sub
Private Sub Make_Directories()
On Error Resume Next
MkDir "C:\Willow Seven"
MkDir "C:\Willow Seven\Setup"
MkDir "C:\Willow Seven\Dll's"
MkDir "C:\Willow Seven\Ocx's"
MkDir "C:\Willow Seven\Program"
End Sub

DeityFox 2001-12-06
  • 打赏
  • 举报
回复
利用API创建文件目录
作者:李志东
Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Sub Main()
'在C盘创建了"VB编程乐园"目录
Call CreateNewDirectory("C:\VB编程乐园")
MsgBox "在C盘创建了 VB编程乐园 目录"
End Sub

Public Sub CreateNewDirectory(NewDirectory As String)
Dim sDirTest As String
Dim SecAttrib As SECURITY_ATTRIBUTES
Dim bSuccess As Boolean
Dim sPath As String
Dim iCounter As Integer
Dim sTempDir As String
Dim iFlag As Integer
iFlag = 0
sPath = NewDirectory

If Right(sPath, Len(sPath)) <> "\" Then
sPath = sPath & "\"
End If

iCounter = 1
Do Until InStr(iCounter, sPath, "\") = 0
iCounter = InStr(iCounter, sPath, "\")
sTempDir = Left(sPath, iCounter)
sDirTest = Dir(sTempDir)
iCounter = iCounter + 1

'创建目录

SecAttrib.lpSecurityDescriptor = &O0
SecAttrib.bInheritHandle = False
SecAttrib.nLength = Len(SecAttrib)
bSuccess = CreateDirectory(sTempDir, SecAttrib)
Loop
End Sub

至于拷贝文件更简单了
FileCopy "c:\a.txt", "c:\program files\a.txt"

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧