Function NetDriverAdd(driver: string): Boolean;
var
NR : TNetResource;
begin
with NR do
begin
dwType := RESOURCETYPE_ANY;
lpLocalName := '';//pchar('W:');
lpRemoteName := pchar(driver);
lpProvider := '';
end;
if WNetAddConnection2(NR, pchar(''), pchar('administrator'), // 密码, 用户名
CONNECT_UPDATE_PROFILE) = NO_ERROR then Result := True else Result := False;
end;
Function NetDriverDisconnect(driver: string): boolean;
begin
if WNetCancelConnection2(pchar(driver), CONNECT_UPDATE_PROFILE,true) = NO_ERROR then Result := True else Result := False;
end;
NetDriverAdd('//10.0.0.0.1/ipc$');
NetDriverDisconnect('//10.0.0.0.1/ipc$');