NetUseDel function (lmuse.h)

The NetUseDel function ends a connection to a shared resource.

You can also use the WNetCancelConnection2 function to terminate a network connection.


  [in] LMSTR UncServerName,
  [in] LMSTR UseName,
  [in] DWORD ForceLevelFlags


[in] UncServerName

The UNC name of the computer on which to execute this function. If this is parameter is NULL, then the local computer is used.

If the UncServerName parameter specified is a remote computer, then the remote computer must support remote RPC calls using the legacy Remote Access Protocol mechanism.

This string is Unicode if _WIN32_WINNT or FORCE_UNICODE are defined.

[in] UseName

A pointer to a string that specifies the path of the connection to delete.

This string is Unicode if _WIN32_WINNT or FORCE_UNICODE are defined.

[in] ForceLevelFlags

The level of force to use in deleting the connection.

This parameter can be one of the following values defined in the lmuseflg.h header file.

Value Meaning
Fail the disconnection if open files exist on the connection.
Do not fail the disconnection if open files exist on the connection.
Close any open files and delete the connection.

Return value

If the function succeeds, the return value is NERR_Success.

If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.


The NetUseDel function applies only to the Server Message Block (LAN Manager Workstation) client. The NetUseDel function does not support Distributed File System (DFS) shares or other network file systems. To terminate a connection to a share using a different network provider (WebDAV or a DFS share, for example), use the WNetCancelConnection2 function.

No special group membership is required to call the NetUseDel function. This function cannot be executed on a remote server except in cases of downlevel compatibility.


Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header lmuse.h (include Lm.h)
Library Netapi32.lib
DLL Netapi32.dll

See also


Network Management Functions

Network Management Overview

Use Functions