您现在的位置:首页 >> 网络通讯 >> 网络通讯 >> 内容

Delphi中映射网络驱动器到虚拟路径

时间:2011/9/3 15:12:27 点击:

  核心提示:function MapNetworkDrive(const handle : THandle; const uncPath : string) : string;//returns mapped d...
function MapNetworkDrive(const handle : THandle; const uncPath : string) : string;
//returns mapped drive ("z:") on success
//or uncPath on failure / cancel

var
  cds : TConnectDlgStruct;
  netResource : TNetResource;
begin
  result := uncPath;

  ZeroMemory(@netResource, SizeOf(TNetResource)) ;
  netResource.dwType := RESOURCETYPE_DISK;
  netResource.lpRemoteName := PChar(uncPath) ;

  cds.cbStructure := SizeOf(TConnectDlgStruct) ;
  cds.hwndOwner := handle;
  cds.lpConnRes := @netResource;
  cds.dwFlags := CONNDLG_PERSIST;

  if WNetConnectionDialog1(cds) = NO_ERROR then
  begin
    result := Chr(-1 + Ord('A') + cds.dwDevNum) + DriveDelim;
  end;
end;
用法:MapNetworkDrive(Application.Handle, '\\server\shared-folder');

作者:网络 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 盒子文章(www.2ccc.com) © 2022 版权所有 All Rights Reserved.
  • 沪ICP备05001939号