|
APIのWNetUseConnectionを使えば、あのダイアログが立ち上がります。
Option Explicit
Private Const RESOURCETYPE_DISK = &H1
Private Const CONNECT_INTERACTIVE = &H8
Private Const CONNECT_PROMPT = &H10
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 WNetUseConnection Lib "mpr.dll" _
Alias "WNetUseConnectionA" ( _
ByVal hwndOwner As Long, _
ByRef lpNetResource As NETRESOURCE, _
ByVal lpUsername As String, _
ByVal lpPassword As String, _
ByVal dwFlags As Long, _
ByVal lpAccessName As Any, _
ByRef lpBufferSize As Long, _
ByRef lpResult As Long) _
As Long
Private Sub CommandButton1_Click()
Dim NetR As NETRESOURCE
Dim ErrInfo As Long
Dim buffer As String
Dim bufferlen As Long
Dim success As Long
NetR.dwType = RESOURCETYPE_DISK
NetR.lpRemoteName = "\\サーバー名" ' 任意
buffer = Space(32)
bufferlen = Len(buffer)
ErrInfo = WNetUseConnection(0, NetR, vbNullString, vbNullString, _
CONNECT_INTERACTIVE Or CONNECT_PROMPT, buffer, bufferlen, success)
End Sub
参考)http://support.microsoft.com/default.aspx?scid=kb%3Bja%3B256847
|
|