#include <windows.h>
#include <stdio.h>
#define USERID "Userid"
#define PASSWORD "Password"
#define REMOTERESOURCE "\\My Network\\share"
#define LOCALDRIVE ""
int main()
{
NETRESOURCE nr;
DWORD ret;
// Initialize NETRESOURCE structure
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = LOCALDRIVE;
nr.lpRemoteName = REMOTERESOURCE;
nr.lpProvider = NULL;
nr.dwDisplayType = NULL;
ret=WNetAddConnection2(&nr,PASSWORD,USERID,0);
if(ret !=NO_ERROR)
{
printf("Problems"
return 1;
}
else printf("Local Drive %s mapped to %s\n", LOCALDRIVE, REMOTERESOURCE);
return 0;
}
I use the above code to log on to a network. Is there any way I can log of the network ie break the connection. Note there is no drive mapped in this code. If you have any questions i will try to explain myself better
#include <stdio.h>
#define USERID "Userid"
#define PASSWORD "Password"
#define REMOTERESOURCE "\\My Network\\share"
#define LOCALDRIVE ""
int main()
{
NETRESOURCE nr;
DWORD ret;
// Initialize NETRESOURCE structure
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = LOCALDRIVE;
nr.lpRemoteName = REMOTERESOURCE;
nr.lpProvider = NULL;
nr.dwDisplayType = NULL;
ret=WNetAddConnection2(&nr,PASSWORD,USERID,0);
if(ret !=NO_ERROR)
{
printf("Problems"
return 1;
}
else printf("Local Drive %s mapped to %s\n", LOCALDRIVE, REMOTERESOURCE);
return 0;
}
I use the above code to log on to a network. Is there any way I can log of the network ie break the connection. Note there is no drive mapped in this code. If you have any questions i will try to explain myself better