Microsoft KB Archive/148391

{|
 * width="100%"|

CheckLCL.exe Finds Corresponding Local Path for UNC Name

 * }

Q148391

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), version 4.0
 * Microsoft Windows NT Workstation versions 3.5, 3.51
 * Microsoft Windows NT Server versions 3.5, 3.51
 * Microsoft Windows 95
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Professional

-

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 \\ \ part with the local path to the share.

MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

"CheckLCL.exe" For additional information about how to download Microsoft Support files, click the article number below to view the article in the Microsoft Knowledge Base:

"Q119591 How to Obtain Microsoft Support Files from Online Services" Microsoft used the most current virus detection software available on the date of posting to scan this file for viruses. Once posted, the file is housed on secure servers that prevent any unauthorized changes to the file.

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.

Additional query words:

Keywords : kbfile kbnetwork kbsample kbAPI kbOSWinNT351 kbOSWin2000 kbSDKPlatform kbOSWin95 kbNetAPI kbOSWinNT350 kbGrpDSNet

Issue type : kbinfo

Technology : kbWinNTsearch kbWinNTWsearch kbWinNT351xsearch kbWinNT350xsearch kbWinNTW350 kbWinNTW350xsearch kbWinNTW351xsearch kbWinNTW351 kbwin2000AdvServ kbwin2000AdvServSearch kbwin2000Serv kbWinNTSsearch kbWinNTS351 kbWinNTS350 kbwin2000ServSearch kbwin2000Search kbwin2000ProSearch kbwin2000Pro kbWinNTS351xsearch kbWinNTS350xsearch kbWin32SDKSearch kbAudDeveloper kbWin95search kbSDKSearch kbWinAdvServSearch kbZNotKeyword3 kbWin32sSearch kbWin32SDK400