' ########################################################################################
' Microsoft Windows
' File: LMUse.inc
' Contents: Structures, function prototypes, and definitions for the NetUse API.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_LMUse_PBI)
#DEFINE PBX_LMUse_PBI
%LMUSE_INC = 1
#include once "lmcons.inc"
#include once "lmuseflg.inc"
'//
'// Function Prototypes
'//
DECLARE FUNCTION NetUseAdd LIB "netapi32.dll" ALIAS "NetUseAdd" ( BYREF UncServerName AS WSTRINGZ , BYVAL Level AS QUAD , BYVAL Buf AS BYTE PTR , BYREF ParmError AS QUAD ) AS QUAD ' NET_API_STATUS
DECLARE FUNCTION NetUseDel LIB "netapi32.dll" ALIAS "NetUseDel" ( BYREF UncServerName AS WSTRINGZ , BYREF UseName AS WSTRINGZ , BYVAL ForceCond AS QUAD ) AS QUAD ' NET_API_STATUS
DECLARE FUNCTION NetUseEnum LIB "netapi32.dll" ALIAS "NetUseEnum" ( BYREF UncServerName AS WSTRINGZ , BYVAL Level AS QUAD , BYREF BufPtr AS ANY , BYVAL PreferedMaximumSize AS QUAD , BYREF EntriesRead AS QUAD , BYREF TotalEntries AS QUAD , BYREF ResumeHandle AS QUAD ) AS QUAD ' NET_API_STATUS
DECLARE FUNCTION NetUseGetInfo LIB "netapi32.dll" ALIAS "NetUseGetInfo" ( BYREF UncServerName AS WSTRINGZ , BYREF UseName AS WSTRINGZ , BYVAL Level AS QUAD , BYREF BufPtr AS ANY ) AS QUAD ' NET_API_STATUS
'//
'// Data Structures
'//
' // Size = 8 bytes
TYPE USE_INFO_0 DWORD
 ui0_local AS WSTRINGZ PTR ' LMSTR ui0_local
 ui0_remote AS WSTRINGZ PTR ' LMSTR ui0_remote
END TYPE
' // Size = 28 bytes
TYPE USE_INFO_1 DWORD
 ui1_local AS WSTRINGZ PTR ' LMSTR ui1_local
 ui1_remote AS WSTRINGZ PTR ' LMSTR ui1_remote
 ui1_password AS WSTRINGZ PTR ' LMSTR ui1_password
 ui1_status AS DWORD ' DWORD ui1_status
 ui1_asg_type AS DWORD ' DWORD ui1_asg_type
 ui1_refcount AS DWORD ' DWORD ui1_refcount
 ui1_usecount AS DWORD ' DWORD ui1_usecount
END TYPE
' // Size = 36 bytes
TYPE USE_INFO_2 DWORD
 ui2_local AS WSTRINGZ PTR ' LMSTR ui2_local
 ui2_remote AS WSTRINGZ PTR ' LMSTR ui2_remote
 ui2_password AS WSTRINGZ PTR ' LMSTR ui2_password
 ui2_status AS DWORD ' DWORD ui2_status
 ui2_asg_type AS DWORD ' DWORD ui2_asg_type
 ui2_refcount AS DWORD ' DWORD ui2_refcount
 ui2_usecount AS DWORD ' DWORD ui2_usecount
 ui2_username AS WSTRINGZ PTR ' LMSTR ui2_username
 ui2_domainname AS WSTRINGZ PTR ' LMSTR ui2_domainname
END TYPE
' // Size = 40 bytes
TYPE USE_INFO_3 DWORD
 ui3_ui2 AS USE_INFO_2 ' USE_INFO_2 ui3_ui2
 ui3_flags AS DWORD ' ULONG ui3_flags
END TYPE
' // Size = 48 bytes
TYPE USE_INFO_4 DWORD
 ui4_ui3 AS USE_INFO_3
 ui4_auth_identity_length AS DWORD
 ui4_auth_identity AS BYTE PTR
END TYPE
'//
'// Special Values and Constants
'//
'//
'// One of these values indicates the parameter within an information
'// structure that is invalid when ERROR_INVALID_PARAMETER is returned by
'// NetUseAdd.
'//
%USE_LOCAL_PARMNUM = 1
%USE_REMOTE_PARMNUM = 2
%USE_PASSWORD_PARMNUM = 3
%USE_ASGTYPE_PARMNUM = 4
%USE_USERNAME_PARMNUM = 5
%USE_DOMAINNAME_PARMNUM = 6
'//
'// Values appearing in the ui1_status field of use_info_1 structure.
'// Note that USE_SESSLOST and USE_DISCONN are synonyms.
'//
%USE_OK = 0
%USE_PAUSED = 1
%USE_SESSLOST = 2
%USE_DISCONN = 2
%USE_NETERR = 3
%USE_CONN = 4
%USE_RECONN = 5
'//
'// Values of the ui1_asg_type field of use_info_1 structure
'//
%USE_WILDCARD = &HFFFFFFFF ' ( (DWORD) (-1) )
%USE_DISKDEV = 0
%USE_SPOOLDEV = 1
%USE_CHARDEV = 2
%USE_IPC = 3
'//
'// Flags defined in the use_info_3 structure
'//
%CREATE_NO_CONNECT = &H1 ' creation flags
%CREATE_BYPASS_CSC = &H2 ' force connection to server, bypassing CSC
 ' all ops on this connection go to the server,
 ' never to the cache
%USE_DEFAULT_CREDENTIALS = &H4 ' No explicit credentials passed to NetUseAdd