扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
![]() 图1 主界面 |
procedure TfrmMain.btnConnectClick(Sender: TObject); var NetShare :NETRESOURCE; begin NetShare.dwType := RESOURCETYPE_DISK; NetShare.lpLocalName := PAnsiChar(edtLocal.Text); NetShare.lpRemoteName := PAnsiChar(edtRemote.Text); NetShare.lpProvider :=’’; WNetAddConnection2(NetShare, ’’, ’’, CONNECT_UPDATE_PROFILE); end; |
procedure TfrmMain.btnDisconnectClick(Sender: TObject); var strLocalName : PChar; begin strLocalName:=PAnsiChar(edtLocal.Text); WNetCancelConnection2(strLocalName,CONNECT_UPDATE_PROFILE,False); end; |
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TfrmMain = class(TForm) btnConnect: TButton; btnDisconnect: TButton; edtLocal: TEdit; Label1: TLabel; Label2: TLabel; edtRemote: TEdit; procedure btnConnectClick(Sender: TObject); procedure btnDisconnectClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmMain: TfrmMain; implementation {$R *.dfm} procedure TfrmMain.btnConnectClick(Sender: TObject); var NetShare :NETRESOURCE; begin NetShare.dwType := RESOURCETYPE_DISK; NetShare.lpLocalName := PAnsiChar(edtLocal.Text); NetShare.lpRemoteName := PAnsiChar(edtRemote.Text); NetShare.lpProvider :=’’; WNetAddConnection2(NetShare, ’’, ’’, CONNECT_UPDATE_PROFILE); end; procedure TfrmMain.btnDisconnectClick(Sender: TObject); var strLocalName : PChar; begin strLocalName:=PAnsiChar(edtLocal.Text); WNetCancelConnection2(strLocalName,CONNECT_UPDATE_PROFILE,False); end; end. |
![]() 图2 程序运行的初始画面 ![]() 图3 输入参数 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。