Network Logon/Logoff Functions

Network Logon/Logoff Functions

I am trying to create a VB program to log a useronto a workgroup (from a windows for workgroupsclient) and then map local drives and devices toa network resource. I am able to map the drivesand devices using the API WNetAddConnection but I do not know an API that will perform the equivalent of net logon and net logoff. Is there such a function?

I did a bit of virtual reading through the Win32 API manuals and did not see anything even remotely close to what you are looking for. Unfortunately, it looks like all of the functions assume that you are logged in before you start doing anything.

However, the WNetAddConnection2 API call is able to take a username and password as parameters to it. Most of the other API calls also have this variation available, so you may want to try it instead of trying to log the user on. The declaration of the API is shown here. For more documentation, refer to the Solutions Development Kit or an API reference book.

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

See also  How HealthStream Learning Center Supports Healthcare Education and Compliance

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist