unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    save: TButton;
    Memo1: TMemo;    procedure FormCreate(Sender: TObject);
    procedure saveClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);//这里读取gg.txt里的内容到memo1里
begin
  memo1.readonly:=ture;
  memo1.Lines.LoadFromFile('服务器地址\c:\gg.txt');
//这里主要有个服务器登录过程,需要用户名和密码,这段代码该怎么写不知道!
end;procedure TForm1.saveClick(Sender: TObject);//保存到服务器的c:\gg.txt里!
begin
  memo1.readonly:=false;
  memo1.Lines.SaveToFile('服务器地址\c:\gg.txt');
end;end.
主要事服务器的登录过程,用户名和密码都已知!(用户名:dsss163,密码:123456)!
文件并不需要下载到自己的客户机上!请大家教教小弟!谢谢了!

解决方案 »

  1.   

    jl820712(seraphim) 是这样的!那我应该怎么做呢?
      

  2.   

    LogonUser
    The LogonUser function attempts to log a user on to the local computer, that is,
    to the computer from which LogonUser was called. You cannot use LogonUser to 
    log on to a remote computer. You specify the user with a user name and domain, 
    and authenticate the user with a clear-text password. If the function succeeds, 
    you receive a handle to a token that represents the logged-on user. You can then
    use this token handle to impersonate the specified user, or in most cases, to 
    create a process running in the context of the specified user. BOOL LogonUser(
      LPTSTR lpszUsername,    // string that specifies the user name
      LPTSTR lpszDomain,      // string that specifies the domain or 
                              // server
      LPTSTR lpszPassword,    // string that specifies the password
      DWORD dwLogonType,      // specifies the type of logon operation
      DWORD dwLogonProvider,  // specifies the logon provider
      PHANDLE phToken         // pointer to variable to receive token 
                              // handle
    );
    或者:
    也可以使用WNet函数,下面的函数WNetAddConnection2是建立同服务器的连接,
    包括共享资源的映射。
    DWORD WNetAddConnection2(
      LPNETRESOURCE lpNetResource,  // connection details
      LPCTSTR lpPassword,           // password
      LPCTSTR lpUsername,           // user name
      DWORD dwFlags                 // connection options
    );
    The WNetAddConnection2 function makes a connection to a network
    resource. The function can redirect a local device to the 
    network resource.
    注意:在9x和NT上该函数的lpPassword,lpUsername只能为空,在NT上你可以指定连接
    的用户和密码。