📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "创建网络映射驱动器"
ClientHeight = 3420
ClientLeft = 60
ClientTop = 345
ClientWidth = 3420
LinkTopic = "Form2"
ScaleHeight = 3420
ScaleWidth = 3420
StartUpPosition = 1 '所有者中心
Begin VB.TextBox Text4
Height = 285
Left = 405
TabIndex = 5
Text = "111"
Top = 2265
Width = 2535
End
Begin VB.TextBox Text3
Height = 285
Left = 405
TabIndex = 4
Text = "MR"
Top = 1665
Width = 2535
End
Begin VB.TextBox Text1
Height = 285
Left = 420
TabIndex = 3
Text = "\\Mr1\e"
Top = 495
Width = 2535
End
Begin VB.TextBox Text2
Height = 285
Left = 435
TabIndex = 2
Text = "M:"
Top = 1095
Width = 2535
End
Begin VB.CommandButton COMMAND1
Caption = "建立"
Height = 405
Left = 645
TabIndex = 1
Top = 2775
Width = 1005
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 405
Left = 1665
TabIndex = 0
Top = 2775
Width = 1005
End
Begin VB.Label Label4
Caption = "密码"
Height = 255
Left = 435
TabIndex = 9
Top = 2025
Width = 2595
End
Begin VB.Label Label3
Caption = "用户"
Height = 255
Left = 405
TabIndex = 8
Top = 1425
Width = 2595
End
Begin VB.Label Label1
Caption = "映射网络路径"
Height = 255
Left = 435
TabIndex = 7
Top = 255
Width = 2595
End
Begin VB.Label Label2
Caption = "映射驱动器名"
Height = 255
Left = 435
TabIndex = 6
Top = 855
Width = 2595
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As String
lpRemoteName As String
lpComment As String
lpProvider As String
End Type
Private Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" _
(lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, _
ByVal dwFlags As Long) As Long
Const NO_ERROR = 0
Const CONNECT_UPDATE_PROFILE = &H1
Const RESOURCETYPE_DISK = &H1
Const RESOURCE_GLOBALNET = &H2
Const RESOURCEDISPLAYTYPE_SHARE = &H3
Const RESOURCEUSAGE_CONNECTABLE = &H1
Private Sub Command1_Click()
Dim NetD As NETRESOURCE
Dim Err As Long
NetD.dwScope = RESOURCE_GLOBALNET
NetD.dwType = RESOURCETYPE_DISK
NetD.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
NetD.dwUsage = RESOURCEUSAGE_CONNECTABLE
NetD.lpRemoteName = Text1.Text
NetD.lpLocalName = Text2.Text
Err = WNetAddConnection2(NetD, Text4.Text, Text3.Text, CONNECT_UPDATE_PROFILE)
If Err = NO_ERROR Then
MsgBox "映射网络驱动器成功!"
Else
MsgBox "映射网络驱动器失败!,请检查网络是否正常连接。"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -