//将 //192.168.1.123/ShareDoc 映射为 X: 盘
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
NRW: TNetResource;
begin
with NRW do
begin
dwType := RESOURCETYPE_ANY;
lpLocalName := pChar(Edit2.Text); // Edit2.Text := X:
lpRemoteName := pChar(Edit1.Text); // //192.168.1.123/ShareDoc
lpProvider := '';
end;
WNetAddConnection2(NRW, 'cxg', 'cxg', CONNECT_UPDATE_PROFILE);
end;
end.