Procedure pr_AddConnection(APath, ALocalDriver, AUserName, APassword:String);
var netSource:TNetResource;
dwResult:DWORD;
sMsg:String;
begin
dwResult := WNetCancelConnection2(PWideChar(APath),
var netSource:TNetResource;
dwResult:DWORD;
sMsg:String;
begin
dwResult := WNetCancelConnection2(PWideChar(APath),
CONNECT_UPDATE_PROFILE,
True);
if APath<>'' then
begin
with netSource do
begin
dwType := RESOURCETYPE_DISK;
lpLocalName := ''; // or H:
lpRemoteName := PWideChar(APath);
lpProvider := '';
dwResult := WNetAddConnection2(netSource,
if APath<>'' then
begin
with netSource do
begin
dwType := RESOURCETYPE_DISK;
lpLocalName := ''; // or H:
lpRemoteName := PWideChar(APath);
lpProvider := '';
dwResult := WNetAddConnection2(netSource,
PWideChar(APassword),
PWideChar(AUsername),
CONNECT_UPDATE_PROFILE);
if dwResult<>NO_ERROR then
begin
sMsg := SysErrorMessage(dwResult);
raise Exception.Create(sMsg);
end;
end;
end;
end;
if dwResult<>NO_ERROR then
begin
sMsg := SysErrorMessage(dwResult);
raise Exception.Create(sMsg);
end;
end;
end;
end;
沒有留言:
張貼留言