I am calling NetUseAdd
to connect to a remote share on local machine (i.e. UncServerName
is null). I am passing level 2 info (i.e. USE_INFO_2
) with username and password to connect. Later when task is done, I am calling NetUseDel
to close the connection using USE_LOTS_OF_FORCE
to close the connection.
My question is: Why NetUseDel
would close the connection even if there are more than one call to NetUseAdd
for same share and same credentials? How to control it (possibly using same force flag). Importantly, what if net use
command is used to add or delete connection? I see the process (having called any of these functions) wouldn't have any control over it.
My point is there should be security or reference-counting for Add, and only when corresponding Delete calls are there, then only OS should close the connection.