Re: network path and use of netsharecheck api....

From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 08/04/04


Date: Wed, 4 Aug 2004 15:10:13 -0400

This appears to work:

Private Declare Function NetShareCheck Lib "netapi32.dll" _
  (servername As Byte, _
   device As Byte, _
   sharetype As Long) As Long

Private Sub Command1_Click()

   Dim sharetype As Long
   Dim success As Long
   Dim bServer() As Byte
   Dim bShare() As Byte

   bServer() = "\\laptopxp" ' -->\\server name
   bShare() = "C:\windows\cursors" ' -->folder to find

   success = NetShareCheck(bServer(0), bShare(0), sharetype)

   Print success & " " & sharetype

End Sub

I have noticed however that the full path to the folder on the remote
machine must be specified, and the drive letter must be upper case. The
correct results seem to be reliably returned if you ucase the entire string,
e.g. bShare() = UCase$("C:\windows\Cursors").

-- 
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"N|O" <foolish3@hotmail.com> wrote in message 
news:vI6Qc.96043$5D1.4929867@news4.tin.it...
: hii, i have to know if a folder, situated in \\server\images (for example)
: exists.
:
: This is the vb code i use:
:
: Private Declare Function NetShareCheck Lib "netapi32.dll" _
:                 (ByVal ServerName As String, _
:                  ByVal Device As String, _
:                  ByRef ShareType As Long) As Long
:
:
: Private Sub Command1_Click()
:  Dim SName As String
:      Dim SHName As String
:      Dim DevType As Long
:      Dim Ans As Long
:
:     SName = Text1.Text     -->\\server name
:     SHName = Text2.Text    -->folder to find
:     DevType = -1
:
:     Ans = NetShareCheck(StrConv(SName, vbUnicode), StrConv(UCase(SHName),
: vbUnicode), DevType)
:     MsgBox Ans, , DevType
: End Sub
:
: devtype return is 0, i think  maybe the server exist, but Ans return
: 2311...this means: NetShareCheck fails with error 2311
: (NERR_DeviceNotShared) when remoted to OS/2.
:
: How can i resolve this?
: Thakns a lot
:
: 


Relevant Pages

  • Re: master volume control in winmm using namespaces
    ... Private Declare Function mixerOpen Lib "WINMM.DLL" (phmx As Long, ... Private Declare Function waveOutSetVolume Lib "WINMM.DLL" (ByVal wDeviceID ... Dim uMixerLine As MIXERLINE ... Private Sub SetWaveVol ...
    (microsoft.public.dotnet.languages.vb)
  • Re: master volume control in winmm using namespaces
    ... Private Declare Function mixerOpen Lib "WINMM.DLL" (phmx As Long, ... Private Declare Function waveOutSetVolume Lib "WINMM.DLL" (ByVal wDeviceID ... Dim uMixerLine As MIXERLINE ... Private Sub SetWaveVol ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Win XP VB6, how to know which process has focus
    ... Private Declare Function GetForegroundWindow _ ... Private Sub Timer1_Timer ... Dim lForegroundWindow As Long ... Dim lTextLength As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: VB6 versus VBNet Challenge
    ... Dim bmp As New Bitmap ... Can I take it that the code loads the existing bitmap ... Private Declare Function GetObject Lib "gdi32" _ ... Private Sub Command1_Click ...
    (microsoft.public.vb.general.discussion)
  • network path and use of netsharecheck api....
    ... Private Declare Function NetShareCheck Lib "netapi32.dll" _ ... Dim SHName As String ... Dim DevType As Long ...
    (microsoft.public.vb.winapi)