home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 August
/
Chip_1999-08_cd.bin
/
zkuste
/
VBasic
/
Data
/
Priklady
/
wnet.bas
< prev
Wrap
BASIC Source File
|
1999-06-16
|
5KB
|
103 lines
Attribute VB_Name = "Module1"
'dwType
Public Const RESOURCETYPE_ANY = &H0
Public Const RESOURCETYPE_DISK = &H1
Public Const RESOURCETYPE_PRINT = &H2
'dwScope
Public Const RESOURCE_CONNECTED = &H1 'vsechny pripojene zdroje
'dwUsage je ignorovano
Public Const RESOURCE_GLOBALNET As Long = &H2& 'vsechny zdroje na siti
Public Const RESOURCE_REMEMBERED = &H3 'vsechny pamatovane zdroje
'dwUsage je ignorovano
'dwUsage
Public Const RESOURCEUSAGE_CONNECTABLE = &H1
Public Const RESOURCEUSAGE_CONTAINER = &H2
'dwFlags pro WNetAddConnection2
Public Const CONNECT_UPDATE_PROFILE = &H1
'Tak byla chyba, nebo ne ?
Public Const NO_ERROR = 0
Public Const ERROR_NO_MORE_ITEMS = 259&
Public Const ERROR_MORE_DATA = 234
Public Const ERROR_NO_NETWORK = 1222&
Public Const ERROR_EXTENDED_ERROR = 1208&
Public Const ERROR_INVALID_HANDLE = 6&
Public Type NETRESOURCE
dwScope As Long
dwType As Long 'Typ zdroje - tiskarna nebo disk
dwDisplayType As Long
dwUsage As Long
lpLocalName As String 'napr. I: nebo LPT1
lpRemoteName As String 'napr. \\KONDOR\KONDOR_C
lpComment As String
lpProvider As String 'nazev pocitace, ke kteremu se chces pripojit
'muze byt NULL
End Type
'Prida pripojeni na sit
Public 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
'lpNetResource pouziva jen dwType,lpLocalName,lpRemoteName a lpProvider
'dwFlags - namapovat pri prihlaseni nebo ne
Public Declare Function WNetAddConnection3 Lib "mpr.dll" Alias "WNetAddConnection3A" _
(hWnd As Long, lpNetResource As NETRESOURCE, ByVal lpPassword As String, _
ByVal lpUsername As String, ByVal dwFlags As Long) As Long
'podobne dvojce, ma vsak handle okna, ke kteremu se budou vztahovat dialogy
'Rusi pripojene spojeni a take rusi automaticke pripojeni, ktere neni zrovna namapovano
Public Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" _
(ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long
'lpName - jestlize lokalni (I:) zrusi jen toto pripojeni, jestli sit (KONDOR) zrusi vse
'dwFlags - pamatovat, nepamatovat
'fForce - jestlize TRUE, zrusi i kdyz je otevreny soubor, jestlize FALSE, hodi chybu
'UkonΦuje "enumeraci" sφ¥ov²ch p°ipojenφ zapoΦatΘho funkcφ WNetOpenEnum
Public Declare Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Long) As Long
'Pripojovaci dialog
Public Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hWnd As Long, _
ByVal dwType As Long) As Long
'Dialog odpojeni
Public Declare Function WNetDisconnectDialog Lib "mpr.dll" (ByVal hWnd As Long, _
ByVal dwType As Long) As Long
'Vracφ poslednφ chybu vzniklou pou₧itφm vÜech t∞chto funkcφ
Public Declare Function WNetGetLastError Lib "mpr.dll" Alias "WNetGetLastErrorA" _
(lpError As Long, ByVal lpErrorBuf As String, ByVal nErrorBufSize As Long, _
ByVal lpNameBuf As String, ByVal nNameBufSize As Long) As Long
'Vracφ informace o sφ¥ovΘm p°ipojenφ
Public Declare Function WNetGetUniversalName Lib "mpr" Alias "WNetGetUniversalNameA" _
(ByVal lpLocalPath As String, ByVal dwInfoLevel As Long, lpBuffer As Any, _
lpBufferSize As Long) As Long
'Vracφ jmΘno aktußln∞ p°ipojenΘho u₧ivatele nebo u₧ivatele pou₧itΘho k sφ¥ovΘmu spojenφ
Public Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" _
(ByVal lpName As String, ByVal lpUsername As String, lpnLength As Long) As Long
'Pokracuje ve vyhledavani zdroju
Public Declare Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" _
(ByVal hEnum As Long, lpcCount As Long, lpBuffer As Any, _
lpBufferSize As Long) As Long
'hEnum je vraceno WNetOpenEnum
'lpcCount kolik jich ma hledat , if=0xFFFFFFFF, hleda vsechno, jestli to skonci OK, vraci tu pocet
'lpBuffer pole NETRESOURCE
'lpBufferSize velikost lpBuffer
'Zacina vypisovat zdroje na siti nebo existujici pripojeni
Public Declare Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" _
(ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage As Long, _
lpNetResource As NETRESOURCE, lphEnum As Long) As Long
'dwScope - co se bude zobrazovat, dwType - klasika
'dwUsage - moc nechapu
'lpNetResource - jestlize NULL, tak hleda od rootu.
'muze byt vyplneno, nebo se pouziva dale pri volani funkce WNetEnumResources
'dwUsage musi byt nastaveno na container
'Jestlize dwScope neni GLOBALNET, musi byt tento NULL
'lphEnum se predava WNetEnumResource