www.pudn.com > virtualdrivemapper.zip > frmCreate.frm
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmCreate
BorderStyle = 3 'Fixed Dialog
Caption = "Create vDrive"
ClientHeight = 3975
ClientLeft = 45
ClientTop = 330
ClientWidth = 6495
Icon = "frmCreate.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3975
ScaleWidth = 6495
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin MSComDlg.CommonDialog CD1
Left = 3360
Top = 240
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Frame Frame1
Height = 4095
Left = 0
TabIndex = 0
Top = -120
Width = 6495
Begin VB.PictureBox picIcon
Height = 540
Left = 1560
ScaleHeight = 529.655
ScaleMode = 0 'User
ScaleWidth = 480
TabIndex = 15
Top = 1920
Width = 540
End
Begin VB.TextBox txtIcon
Height = 285
Left = 2160
Locked = -1 'True
TabIndex = 14
ToolTipText = "vDrive mapped folder path."
Top = 2040
Width = 1935
End
Begin VB.CommandButton cmdCancel
Caption = "C&ancel"
Height = 375
Left = 3840
TabIndex = 13
Top = 3600
Width = 1095
End
Begin VB.CommandButton cmdClear
Caption = "C&lear All"
Height = 375
Left = 5280
TabIndex = 11
Top = 3120
Width = 1095
End
Begin VB.CheckBox chkFLD
Caption = "Create New Folder"
Height = 255
Left = 1560
TabIndex = 9
ToolTipText = "Check to create a new folder."
Top = 1200
Width = 1695
End
Begin VB.CommandButton cmdFolder
Caption = "Select Folder"
Height = 375
Left = 4200
TabIndex = 6
Top = 840
Width = 1095
End
Begin VB.TextBox txtPath
Height = 285
Left = 1560
TabIndex = 5
ToolTipText = "vDrive mapped folder path."
Top = 840
Width = 2535
End
Begin VB.ComboBox cboDrv
Height = 315
ItemData = "frmCreate.frx":0442
Left = 1560
List = "frmCreate.frx":0444
TabIndex = 3
Text = "Select Drive"
ToolTipText = "Available vDrive letter to use."
Top = 360
Width = 1695
End
Begin VB.CommandButton cmdIcon
Caption = "Select Icon"
Height = 375
Left = 4200
TabIndex = 2
Top = 2040
Width = 1095
End
Begin VB.CommandButton cmdCreate
Caption = "&Create"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 5280
TabIndex = 1
Top = 3600
Width = 1095
End
Begin VB.Image imgDefault
Height = 480
Left = 5400
Picture = "frmCreate.frx":0446
Top = 2040
Visible = 0 'False
Width = 480
End
Begin VB.Label Label3
Caption = "If no icon selected then the vDrive icon will be the default hard drive icon."
Height = 375
Left = 1560
TabIndex = 12
Top = 2640
Width = 3615
End
Begin VB.Label Label2
Caption = "To create a new folder just enter a path and a new folder name and click the check box. To select one, press the button."
Height = 375
Left = 1560
TabIndex = 10
Top = 1440
Width = 4815
End
Begin VB.Label lblDrv
Alignment = 1 'Right Justify
Caption = "Available Drives:"
Height = 255
Left = 120
TabIndex = 8
Top = 360
Width = 1335
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Virtual Drive Icon:"
Height = 255
Left = 120
TabIndex = 7
Top = 2040
Width = 1335
End
Begin VB.Label lblPath
Alignment = 1 'Right Justify
Caption = "Map Folder Path:"
Height = 255
Left = 120
TabIndex = 4
Top = 840
Width = 1335
End
End
Begin VB.Menu mnuTray
Caption = "Hidden Menu"
Visible = 0 'False
Begin VB.Menu mnuVirtual
Caption = "&Open Virtual Drive"
End
End
End
Attribute VB_Name = "frmCreate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'/////////////////////////////////////////////////////////
'Copyright © 2001 B.O.O.P.S. Inc.
'BOOPS, Based On Other People's Stuff
'We don't code the source you download, we code it better.
'Original only in the synthesis.
'
'This program is based on Ian O'Connor's(oc@lineone.net) vb script file
'"Directory Mapping.vbs" with revisions by Neil Ramsbottom(nramsbottom@hotmail.com).
'It was included in the zip.
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Option Explicit
Private R As New cReg 'registy class module.
Dim CreateNewFLD As Boolean, NewIco As Boolean
Dim nVdrv As Integer
'/////////////////////////////////////////////////////////
Private Sub Form_Load()
Dim i As Integer, filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
picIcon.Picture = imgDefault.Picture
'Only add drives not in use.
For i = 65 To 90 'Runs through A to Z adding available drives.
If filesys.DriveExists(Chr(i) & ":") Then
'Unavailable drive = Do nothing
Else
cboDrv.AddItem Chr(i) & ":\"
End If
Next
Set filesys = Nothing
End Sub
Private Sub cmdFolder_Click()
frmFolder.Show
End Sub
Private Sub cmdIcon_Click()
With CD1
.Filter = "Icon (*.ico)|*.ico"
.DialogTitle = "Open"
.ShowOpen
picIcon.Picture = LoadPicture(.Filename)
txtIcon.Text = .Filename
End With
End Sub
Private Sub cmdClear_Click()
cboDrv.Text = "Select Drive"
txtPath.Text = ""
picIcon.Picture = imgDefault.Picture
txtIcon.Text = ""
End Sub
Private Sub cmdCreate_Click()
If Right$(cboDrv.Text, 2) <> ":\" Then
MsgBox "Drive not selected.", vbInformation, "Error Creating Virtual Drive"
Exit Sub
End If
If txtPath.Text = "" Then
MsgBox "No folder specified.", vbInformation, "Error Creating Virtual Drive"
Exit Sub
End If
If txtIcon.Text = "" Then
NewIco = False
Else
NewIco = True
End If
If VirtualDrv = True Then MsgBox "Virtual Drive Successfully Created" & vbCrLf & "vDrive on: " & cboDrv.Text & vbCrLf & "Mapped to: " & txtPath.Text, vbInformation, "vDrive Created"
frmMain.fraMain.Enabled = True
frmMain.vDirRefresh
Unload Me
End Sub
Private Sub cmdCancel_Click()
frmMain.fraMain.Enabled = True
Unload Me
End Sub
Function VirtualDrv() As Boolean
On Error Resume Next
Dim mapPath As String, numVdrv As String
Dim filesys, drv, wsh
mapPath = txtPath.Text 'Set the mapped folder path.
drv = Left$(cboDrv.Text, 2) 'Set the vdrive letter.
Set filesys = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("WScript.Shell")
'Do according to wheather or not user chose to create a new folder for the vDrive.
If CreateNewFLD = True Then
If filesys.FolderExists(mapPath) Then 'Determine if folder already exists.
MsgBox "The folder " & mapPath & " already exists!" & vbCrLf & "Choose a different folder name.", vbCritical, "Error in creating vDrive"
Exit Function
Else
If filesys.DriveExists(Right(mapPath, 2)) Then 'Determine if drive is available.
If filesys.DriveType(Right(mapPath, 2)) = Fixed Then 'Determine if it is a hard drive.
filesys.CreateFolder (mapPath)
wsh.Run ("subst " & drv & " " & mapPath)
Else
MsgBox "You can only create a new folder on a hard drive.", vbCritical, "Error in creating vDrive"
End If
Else
MsgBox "Drive " & Right(mapPath, 3) & " is not available.", vbCritical, "Error in creating vDrive"
End If
End If
Else
wsh.Run ("subst " & drv & " " & mapPath)
End If
'prevent errors doing some DoEvents
DoEvents
If NewIco = True Then
FileCopy txtIcon.Text, mapPath & "\vDrive.ico"
DoEvents
Open mapPath & "\Autorun.inf" For Output As 1
Print #1, "[autorun]"
Print #1, "icon=vDrive.ico"
Close #1
'hide these files, not really necessary, but oh well.
SetAttr mapPath & "\vDrive.ico", vbHidden
SetAttr mapPath & "\Autorun.inf", vbHidden
End If
'Set registry settings.
numVdrv = R.qVal(&H80000001, "Software\BOOPS", "Loaded")
R.SetKeyValue &H80000001, "Software\BOOPS", "Loaded", numVdrv + 1, REG_SZ
R.CreateNewKey &H80000001, "Software\BOOPS\" & drv
R.SetKeyValue &H80000001, "Software\BOOPS\" & drv, "vMap", mapPath, REG_SZ
R.SetKeyValue &H80000001, "Software\BOOPS\" & drv, "vIcon", NewIco, REG_SZ
Set filesys = Nothing
Set wsh = Nothing
'function succedded, return true.
VirtualDrv = True
End Function
Private Sub chkFLD_Click()
If chkFLD.Value = 1 Then
CreateNewFLD = True
Else
CreateNewFLD = False
End If
End Sub