vb 磁盘映射

前端之家收集整理的这篇文章主要介绍了vb 磁盘映射前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. VERSION5.00
  2. BeginVB.FormForm1
  3. Caption="Form1"
  4. ClientHeight=3195
  5. ClientLeft=60
  6. ClientTop=345
  7. ClientWidth=4680
  8. LinkTopic="Form1"
  9. ScaleHeight=3195
  10. ScaleWidth=4680
  11. StartUpPosition=3'窗口缺省
  12. BeginVB.TextBoxText1
  13. Height=360
  14. Left=1260
  15. TabIndex=1
  16. Top=1110
  17. Width=2475
  18. End
  19. BeginVB.CommandButtonCommand1
  20. Caption="Command1"
  21. Height=390
  22. Left=1515
  23. TabIndex=0
  24. Top=2220
  25. Width=1620
  26. End
  27. BeginVB.LabelLabel1
  28. AutoSize=-1'True
  29. BackStyle=0'Transparent
  30. Caption="路径:"
  31. Height=180
  32. Left=525
  33. TabIndex=2
  34. Top=1125
  35. Width=540
  36. End
  37. End
  38. AttributeVB_Name="Form1"
  39. AttributeVB_GlobalNameSpace=False
  40. AttributeVB_Creatable=False
  41. AttributeVB_PredeclaredId=True
  42. AttributeVB_Exposed=False
  43. OptionExplicit
  44. PrivateConstCONNECT_UPDATE_PROFILE=
  45. PrivateConstRESOURCE_CONNECTEDAsLong=&H1
  46. PrivateConstRESOURCE_GLOBALNETAsLong=&H2
  47. PrivateConstRESOURCETYPE_DISKAsLong=&H1
  48. PrivateConstRESOURCEDISPLAYTYPE_SHARE&=
  49. PrivateConstRESOURCEUSAGE_CONNECTABLEAsLong=&H1
  50. PrivateDeclareFunctionWNetAddConnection2Lib"mpr.dll"Alias"WNetAddConnection2A"(lpNetResourceAsNETCONNECT,ByVallpPasswordAsString,ByVallpUserNameAsString,ByValdwFlagsAsLong)AsLong
  51. PrivateTypeNETCONNECT
  52. dwScopeAsLong
  53. dwTypeAsLong
  54. dwDisplayTypeAsLong
  55. dwUsageAsLong
  56. lpLocalNameAsString
  57. lpRemoteNameAsString
  58. lpCommentAsString
  59. lpProviderAsString
  60. EndType
  61. PublicFunctionMapDrive(LocalDriveAsString,RemoteDriveAsString,OptionalUsernameAsString,OptionalPasswordAsString)AsBoolean
  62. DimNetRAsNETCONNECT
  63. NetR.dwScope=RESOURCE_GLOBALNET
  64. NetR.dwType=RESOURCETYPE_DISK
  65. NetR.dwDisplayType=RESOURCEDISPLAYTYPE_SHARE
  66. NetR.dwUsage=RESOURCEUSAGE_CONNECTABLE
  67. NetR.lpLocalName=Left$(LocalDrive,1)&":"
  68. NetR.lpRemoteName=RemoteDrive
  69. MapDrive=(WNetAddConnection2(NetR,Username,Password,CONNECT_UPDATE_PROFILE)=0)
  70. EndFunction
  71. PrivateSubCommand1_Click()
  72. IfMapDrive("I:",Text1.Text)Then
  73. MsgBox"映射网络驱动器成功"
  74. Else
  75. MsgBox"映射网络驱动器失败"
  76. EndIf
  77. EndSub

猜你在找的VB相关文章