请说明详细步骤
热心网友
建立网络驱动器的映射。voidCMountDlg::OnMountButton(){// [MAX_PATH];//输入的网络路径m_NetpathEdit。GetWindowText(netpath,sizeof(netpath));chardrv[MAX_PATH];//本地的驱动器盘符m_DriveEdit。GetWindowText(drv,sizeof(drv));NETRESOURCEnetres;netres。dwScope=RESOURCE_GLOBALNET;netres。dwType=RESOURCETYPE_ANY;netres。dwDisplayType=RESOURCEDISPLAYTYPE_GENERIC;netres。dwUsage=RESOURCEUSAGE_CONNECTABLE;netres。lpLocalName=drv;netres。lpRemoteName=netpath;netres。lpComment=NULL;netres。lpProvider=NULL;DWORDrslt=WNetAddConnection2(&netres,NULL,NULL,0);CStringstr;str。Format("WNetAddConnection2()returncode=%d",rslt);MessageBox(str);}取消网络驱动器的映射voidCMountDlg::OnUnmountButton(){// [MAX_PATH];//本地的驱动器盘符m_DriveEdit。GetWindowText(drv,sizeof(drv));DWORDrslt=WNetCancelConnection2(drv,0,FALSE);CStringstr;str。Format("WNetCancelConnection2()returncode=%d",rslt);MessageBox(str);//显示信息成功与否returncode=0成功否则建立失败}。