Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#include <windows.h> #include <std

Status
Not open for further replies.

nerram

Programmer
Apr 23, 2003
56
IE
#include <windows.h>
#include <stdio.h>
#define USERID &quot;Userid&quot;
#define PASSWORD &quot;Password&quot;
#define REMOTERESOURCE &quot;\\My Network\\share&quot;
#define LOCALDRIVE &quot;&quot;
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(&quot;Problems&quot;);
return 1;
}
else printf(&quot;Local Drive %s mapped to %s\n&quot;, 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
 
how about:
WNetCancelConnection

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top