請說明詳細步驟
熱心網友
建立網絡驅動器的映射。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成功否則建立失敗}。