前端之家收集整理的这篇文章主要介绍了
vb 磁盘映射,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
- VERSION5.00
- BeginVB.FormForm1
- Caption="Form1"
- ClientHeight=3195
- ClientLeft=60
- ClientTop=345
- ClientWidth=4680
- LinkTopic="Form1"
- ScaleHeight=3195
- ScaleWidth=4680
- StartUpPosition=3
- BeginVB.TextBoxText1
- Height=360
- Left=1260
- TabIndex=1
- Top=1110
- Width=2475
- End
- BeginVB.CommandButtonCommand1
- Caption="Command1"
- Height=390
- Left=1515
- TabIndex=0
- Top=2220
- Width=1620
- End
- BeginVB.LabelLabel1
- AutoSize=-1
- BackStyle=0
- Caption="路径:"
- Height=180
- Left=525
- TabIndex=2
- Top=1125
- Width=540
- End
- End
- AttributeVB_Name="Form1"
- AttributeVB_GlobalNameSpace=False
- AttributeVB_Creatable=False
- AttributeVB_PredeclaredId=True
- AttributeVB_Exposed=False
- OptionExplicit
- PrivateConstCONNECT_UPDATE_PROFILE=
- PrivateConstRESOURCE_CONNECTEDAsLong=&H1
- PrivateConstRESOURCE_GLOBALNETAsLong=&H2
- PrivateConstRESOURCETYPE_DISKAsLong=&H1
- PrivateConstRESOURCEDISPLAYTYPE_SHARE&=
- PrivateConstRESOURCEUSAGE_CONNECTABLEAsLong=&H1
- PrivateDeclareFunctionWNetAddConnection2Lib"mpr.dll"Alias"WNetAddConnection2A"(lpNetResourceAsNETCONNECT,ByVallpPasswordAsString,ByVallpUserNameAsString,ByValdwFlagsAsLong)AsLong
- PrivateTypeNETCONNECT
- dwScopeAsLong
- dwTypeAsLong
- dwDisplayTypeAsLong
- dwUsageAsLong
- lpLocalNameAsString
- lpRemoteNameAsString
- lpCommentAsString
- lpProviderAsString
- EndType
- PublicFunctionMapDrive(LocalDriveAsString,RemoteDriveAsString,OptionalUsernameAsString,OptionalPasswordAsString)AsBoolean
- DimNetRAsNETCONNECT
- NetR.dwScope=RESOURCE_GLOBALNET
- NetR.dwType=RESOURCETYPE_DISK
- NetR.dwDisplayType=RESOURCEDISPLAYTYPE_SHARE
- NetR.dwUsage=RESOURCEUSAGE_CONNECTABLE
- NetR.lpLocalName=Left$(LocalDrive,1)&":"
- NetR.lpRemoteName=RemoteDrive
- MapDrive=(WNetAddConnection2(NetR,Username,Password,CONNECT_UPDATE_PROFILE)=0)
- EndFunction
- PrivateSubCommand1_Click()
- IfMapDrive("I:",Text1.Text)Then
- MsgBox"映射网络驱动器成功"
- Else
- MsgBox"映射网络驱动器失败"
- EndIf
- EndSub
原文链接:https://www.f2er.com/vb/264381.html