Welcome 微信登录
编程资源 图片资源库

首页 / 软件开发 / Delphi / DELPHI中映射网络驱动器

DELPHI中映射网络驱动器2007-11-16function WNetAddConnection2W(var lpNetResource: TNetResourceW;lpPassword, lpUserName: PWideChar; dwFlags: DWORD): DWORD; stdcall;

首先要填一个 lpNetResource structure,然后 password,user name, 和一个标志表明是否这个映射每次登录时都要还原。详情见帮助。

var

NRW: TNetResource;

begin

with NRW do begin dwType := RESOURCETYPE_ANY;

lpLocalName := "X:"; // map to this driver letter

lpRemoteName := "MyServerMyDirectory";

// Must be filled in. If an empty string is used,

// it will use the lpRemoteName. lpProvider := ""; end;

WNetAddConnection2(NRW, "MyPassword", "MyUserName", CONNECT_UPDATE_PROFILE);

end;