CSDN博客

img wangzn1979

如何访问局域网上的文件

发表于2003/3/15 10:20:00  543人阅读

var
  NetSource : TNetResource;    file://连接服务器结构
  dwResult:DWORD;               file://连接文件服务器的返回值

procedure ConnectServer;
begin
    g_bFlag:=True;
    NetSource.dwType:= RESOURCETYPE_ANY;
    NetSource.lpLocalName:='';
    NetSource.lpRemoteName:=PAnsiChar('//'+g_sServerIp);
    NetSource.lpProvider:='';
    dwResult:=WnetAddConnection2(NetSource,PAnsiChar(g_sServerPassWord),PAnsiChar(g_sServerUserName),CONNECT_UPDATE_PROFILE);
    if dwResult<>0 then
    begin
        MessageDlg('连接文件服务器失败!'#13#10'请重新设置!',mtWarning,[mbOk],0);
        g_bFlag:=False;
    end;
end;

procedure DisconnectServer;
begin
    if g_bFlag then
        WNetCancelConnection2(PAnsiChar('//'+g_sServerIp), CONNECT_UPDATE_PROFILE, True);
end;

阅读全文
0 0

相关文章推荐

img
取 消
img