给一段BCB程序:
void __fastcall TForm1::Button2Click(TObject *Sender)
{
DWORD dwResult; dwResult = WNetConnectionDialog(Handle, RESOURCETYPE_DISK);
if(dwResult == NO_ERROR)
{
StatusBar1->SimpleText="映射驱动器成功";
}
else
{
StatusBar1->SimpleText="映射驱动器失败";
NetErrorHandler(dwResult, (LPSTR)"WNetConnectionDialog");
return;
}}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
DWORD dwResult; dwResult = WNetConnectionDialog(Handle, RESOURCETYPE_DISK);
if(dwResult == NO_ERROR)
{
StatusBar1->SimpleText="映射驱动器成功";
}
else
{
StatusBar1->SimpleText="映射驱动器失败";
NetErrorHandler(dwResult, (LPSTR)"WNetConnectionDialog");
return;
}}
WNetAddConnection('\\ntserver\demo','YourPassword','i:');
如果没有密码,就让他为空。
返回值:
wn_success成功
器它的自己看帮助。
断开的话用:
WNetCancelConnection('I:',bFlag);
其中bFlag标志是否强行断开映射。
dwResult=WNetConnectionDialog(Handle,RESOURCETYPE_DISK);
if(dwResult==NO_ERROR)
{ //成功;}
else{//失败;}
var
dwResult :DWORD ;
begindwResult := WNetConnectionDialog(Handle, RESOURCETYPE_DISK);
if(dwResult = NO_ERROR)then
begin
showmessage('映射驱动器成功');
end else
begin
showmessage('映射驱动器失败');
//NetErrorHandler(dwResult, 'WNetConnectionDialog');
exit;
end;
end;