SAMPLE: CheckLCL.exe Finds Corresponding Local Path for UNC Name
ID: Q148391
|
The information in this article applies to:
-
Microsoft Win32 Software Development Kit (SDK), version 4.0
-
Microsoft Windows NT Workstation versions 3.50, 3.51
-
Microsoft Windows NT Server versions 3.5, 3.51
-
Microsoft Windows 95
SUMMARY
UNC names specify network-wide distinct locations that are useful to
provide configuration information for applications. However, when the UNC
name refers to the local computer, it introduces some overhead because the
requests are passed down the Redirector, looped back by the transport, and
sent to the server service instead of going directly to the local disk.
The function provided in the library file in the CheckLCL.exe sample checks
the name passed it against the local computer name and replaces the
\\<computer>\<share> part with the local path to the share.
MORE INFORMATION
The following file is available for download from the Microsoft
Software Library:
~ CheckLCL.exe
For more information about downloading files from the Microsoft Software
Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services
Limitations or Caveats
- The function only resolves names in the Microsoft Windows Network. It
doesn't work with FPNW.
- Because the changed names do not hit server service anymore, share
security does not apply. But this is alright because the function, which
is called to resolve the name, can only be called by Admin type accounts
on Windows NT. On Windows 95, there is no local security anyway.
The CheckLCL library has three callable functions: GlpGetLocalPathName,
GlpFreeBuffer, and GlpGetBuffer.
The GlpGetLocalPathName Function
GlpGetLocalPathName( IN LPCTSTR pszInputName,
IN OUT LPTSTR *ppszOutputName,
IN OUT LPDWORD pdwOutputNameLength,
OPTIONAL OUT LPDWORD pdwLanManError,
OPTIONAL IN NETSHAREGETINFO_FPTR __stdcall
GlpNetShareGetInfoPtr
);
To successfully execute the GlpGetLocalPathName function, you need to have
administrative or server operator privileges on Windows NT. Also, the
network should be running. The GlpGetLocalPathName function supports file,
pipe, and mailslot share names. It also supports the use of path names
longer than 260 characters (syntax \\?\ in CreateFile). For more
information, please see the header file.
PszInputName:
The GlpGetLocalPathName function scans the name passed in pszInputName and
tries to convert it to a local file path, if it's a UNC name referencing
the local computer name.
PpszOutputName:
ppszOutputName contains the local path name if the return code is
ERROR_GLP_SUCCESS. In any other case, the contents should be ignored. The
GlpGetLocalPathName function will allocate memory if you pass a pointer to
NULL. You should free the pointer using GlpFreeBuffer.
PdwOutputNameLength:
When you pass a pointer to memory in ppszOutputName, this parameter
specifies the number of characters that can be stored there including the
terminating NULL character.
When the GlpGetLocalPathName function returns ERROR_GLP_SUCCESS, this
pdwOutputNameLength variable contains the number of characters copied into
the buffer.
If the function returns ERROR_GLP_INSUFFICIENT_BUFFER or
ERROR_GLP_INSUFFICIENT_MEMORY, the pdwOutputNameLength variable contains
the number of characters needed to store the converted name.
PdwLanManError:
This optional parameter points to a DWORD that receives the error code
returned by NetShareEnum if the return code is ERROR_GLP_LANMAN_ERROR. The
value is not changed when NetShareEnum returns successfully. If you're not
interested in this value, pass NULL to the function.
GlpNetShareGetInfoPtr:
If not NULL, this function pointer will be called instead of NetShareEnum.
This gives the caller the possibility to provide the local name or to call
some other API. The parameters passed are for a call to NetShareEnum with
information level 2. Remember that this function is UNICODE only.
The GlpFreeBuffer Function
GlpFreeBuffer (PVOID *ppszBuffer);
This function frees a pointer returned from GlpGetLocalPathName in the
parameter ppszOutputName. The function sets the pointer to NULL after the
memory is freed.
The GlpGetBuffer Function
GlpGetBuffer (PVOID *ppszBuffer, DWORD dwSizeNeeded);
Use this function if you pass a pointer to your custom NetShareGetInfo
function to GlpGetLocalPathNameW to allocate memory for the bufptr output
parameter of NetShareGetInfo. GlpGetLocalPathNameW uses its GlpFreeBuffer
function to free the memory.
This function returns ERROR_GLP_SUCCESS on success and
ERROR_GLP_INSUFFICIENT_MEMORY if there is not enough memory.
Keywords : kbfile kbnetwork kbsample kbAPI kbNTOS350 kbNTOS351 kbSDKPlatform kbWinOS95 kbNetAPI kbGrpNet
Version :
Platform :
Issue type :
Last Reviewed: March 10, 1999