Click here to Skip to main content
11,641,659 members (62,708 online)
Click here to Skip to main content

Sharing resources in the local network with VB 6.0

, 30 Aug 2007 37.1K 780 11
Rate this:
Please Sign up or sign in to vote.
How to share folders in a network with VB 6.0
  • <a href="VBNetworkResources/clsVBNetwork.zip">Download source file - 3 Kb</a>

Introduction


In my local network, it is common an equipment to be turned off and others have mapped folders of it. Windows shows a warning window. It informs that the resource is not available in the moment and that the operator can choose for not more to use the unavailable resource.

Each user when doing logon, it's executed for he a script. This script makes all it adjusts them and necessary updatings in the system. I then opted to not to show any window type and simply to ignore the mistake screens.

My reality

There is a service that resides in all the equipments. It verifies periodically for updating files. When an user makes logon, the others are informed of the event (like MSN Messeger). The personal computer seeks for events associated the user and it executes.


Common events

The most common events are:
- to map a resource,
- to post a file,
- warnings,


Solution

I use applications VB to work the system. Then, I developed a small class to map the resources.

Example

My reports are printed like PDF and published in the browser. Then:

  
Sub MapReportFolder()  
Dim Net As New clsNetworkClient  
Dim Ret As Long  
  
    Ret = Net.Connect("R:", "\\<a href="file://ESRVD048829A03/REPORT">ESRVD048829A03\REPORT</a>", Net.ComputerName, "")  


<pre lang="vb.net"> 
    If Not Ret = 0 Then  
       Call LogEvent (date, time, WnetError(Ret))  
    End If  

End Sub  

Error Trap

The return code can be tested and show a mensage to user:

Private Const ERROR_SUCCESS As Integer = 0
Private Const WN_Success As Long = &H0
Private Const WN_Not_Supported As Long = &H1
Private Const WN_Net_Error As Long = &H2
Private Const WN_Bad_Pointer As Long = &H4
Private Const WN_Bad_NetName As Long = &H32
Private Const WN_Bad_Password As Long = &H6
Private Const WN_Bad_Localname As Long = &H33
Private Const WN_Access_Denied As Long = &H7
Private Const WN_Out_Of_Memory As Long = &HB
Private Const WN_Already_Connected As Long = &H34
Private Function WnetError(ByVal Errcode As Long) As String
    Select Case Errcode
        Case WN_Not_Supported
        WnetError = "Function is Not supported."
      Case WN_Out_Of_Memory
        WnetError = "Out of Memory."
      Case WN_Net_Error
        WnetError = "An error occurred On the network."
      Case WN_Bad_Pointer
        WnetError = "The Pointer was Invalid."
      Case WN_Bad_NetName
        WnetError = "Invalid Network Resource Name."
      Case WN_Bad_Password
        WnetError = "The Password was Invalid."
      Case WN_Bad_Localname
        WnetError = "The local device name was invalid."
      Case WN_Access_Denied
        WnetError = "A security violation occurred."
      Case WN_Already_Connected
        WnetError = "The local device was connected To a remote resource."
      Case Else
        WnetError = "Unrecognized Error " + Str(Errcode) + "."
    End Select
End Function

Gratefulness

My sincere gratefulness to the friend Wilsimar Araújo, a fantastic Designer.

Contact

MSN: willian_cpp_br@hotmail.com
Phone: +55 (61) 9162-8541

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

WillianBR
Software Developer
Brazil Brazil
Developer:
- MS VB6
- C/C++/C#
- VBScript
- JScript
- Clipper
- Cobol
- Natural
- Pascal
- TCL/Tk
- Python
___________________________________
Willian Silva Rodrigues
http://www.williansilva.com.br
http://br.linkedin.com/in/willianbr
--- --- --- ---
Radio(NXTL):55*112*109193
BBM PIN: 238d4349
___________________________________

You may also be interested in...

Comments and Discussions

 
GeneralError Messages Pin
frankzappa29-Aug-07 18:19
memberfrankzappa29-Aug-07 18:19 
GeneralRe: Error Messages Pin
Willian.BR30-Aug-07 6:03
memberWillian.BR30-Aug-07 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150731.1 | Last Updated 30 Aug 2007
Article Copyright 2004 by WillianBR
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid