I try to connect to the c$
share on an old Windows NT4 SP6 Machine via WNetAddConnection2
.
This is the Code i used:
int main() {
NETRESOURCE nr;
std::string remote{"\\\\192.168.178.22\\c$"}
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = NULL;
nr.lpRemoteName = remote.data();
nr.lpProvider = NULL;
auto res = WNetAddConnection2(&nr, "test", "User", NULL);
if (res == NO_ERROR) {
std::cout << "Connected\n";
} else {
std::cout << res << '\n';
}
}
This just give me the Error Code 86
which stands for:
The specified network password is not correct.
If i try to mount the Share via net use
like so:
net use \\192.168.178.22\c$ /user:User
And give the same Password when prompted for it the connection is successfully made.
Is there something wrong with my Code? Or do i miss something?
Because for me it's strange that the Connection works with net use
but not with the WNetAddConnection2
Function.