HOWTO: Call LAN Manager Functions from 16-bit Visual Basic 4.0Last reviewed: August 13, 1997Article ID: Q159423 |
The information in this article applies to:
SUMMARYThe Win32 network service APIs ported from LAN Manager are Unicode and used by Windows NT only. For Windows 95, you must use the 16-bit LAN Manager functions. This article illustrates how to call the 16-bit LAN Manager functions from a Visual Basic 4.0 16-bit application.
MORE INFORMATIONThe following sample application retrieves network information for a specified user. It uses two TextBoxes to collect the domain name and the user name. It then calls NetGetDCName to get the name of the Primary Domain Controller (PDC) for the specified domain. Once the application retrieves the PDC, it calls NetUserGetGroups to retrieve the list of global groups and NetUserGetInfo to retrieve the USER_INFO_10 structure. See the REFERENCES section of this article for more information.
Step-by-Step Example
Private Declare Function LStrCpy Lib "kernel" (ByVal Dest As String, _ ByVal Source As Any) As Integer Private Declare Function NetGetDCName Lib "NETAPI.DLL" ( _ ByVal server As String, ByVal domain As String, ByVal buffer As _ String, ByVal cbBuffer As Integer) As Integer Private Declare Function NetUserGetInfo Lib "NETAPI.DLL" (ByVal server _ As String, ByVal UserName As String, ByVal level As Integer, buffer _ As Any, ByVal cbBuffer As Integer, pcbTotal As Integer) As Integer Private Declare Function NetUserGetGroups Lib "NETAPI.DLL" (ByVal server _ As String, ByVal UserName As String, ByVal level As Integer, ByVal _ buffer As String, ByVal cbBuffer As Integer, cEntriesRead As _ Integer, cTotalAvail As Integer) As IntegerPrivate Type USER_INFO_10 usri10_name As String * 22 usri10_comment As Long usri10_usr_comment As Long usri10_full_name As Long usri10_extraspace As String * 400End Type Private Type group_users_info_0 grui0_name As String * 22End Type Private UserI As USER_INFO_10 Private Group As group_users_info_0 Public Function PointerToString(Pointer As Long) As String Dim res As Integer Dim buffer As String * 80 buffer = String(80, 0) If Pointer > 0 Then res = LStrCpy(buffer, Pointer) End If PointerToString = Left(buffer, InStr(buffer, Chr(0)) - 1)End Function
REFERENCESThe following article in the Microsoft Knowledge Base demonstrates techniques that are useful in calling most 32-bit network service APIs on Windows NT from a Visual Basic 4.0 32-bit application:
ARTICLE-ID: Q151774 TITLE : How to Call NetUserGetInfo from Visual Basic 4.0(c) Microsoft Corporation 1996, All Rights Reserved. Contributions by Wei Hua, Microsoft Corporation Keywords : APrgNet vb416 VB4WIN kbhowto Version : 4.0 Platform : NT WINDOWS |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |