📄 logpas.pas
字号:
unit LogPas;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TLogForm = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
SName: TEdit;
SPass: TEdit;
Button2: TButton;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
LogForm: TLogForm;
implementation
{$R *.DFM}
procedure TLogForm.Button1Click(Sender: TObject);
var RES: TNetResource;
RName, CPass, CName: PChar;
WError: Word;
SError: string;
begin
GetMem(CPass, 20);
GetMem(CName, 20);
GetMem(RName, 20);
StrPCopy(CPass, SPass.Text);
StrPCopy(CName, SName.Text);
StrPCopy(RName, Label3.Caption);
Res.dwType := 0;
Res.lpLocalName := '';
Res.lpProvider := '';
Res.lpRemoteName := RName;
WError := WNetAddConnection2(Res, CPass, CName, 0);
if No_Error = WError then ModalResult := mrOK
else begin case WError of
1: SError := '指定的密码或用户名对该资源无效。';
ERROR_ACCESS_DENIED: SError := '网络拒绝你的访问。';
ERROR_ALREADY_ASSIGNED: SError := '指定的逻辑设备已经连接到别的网络资源。';
ERROR_BAD_DEV_TYPE: SError := '逻辑设备和网络资源不匹配。';
ERROR_BAD_DEVICE: SError := '非法的设备名称。';
ERROR_BAD_NET_NAME: SError := '无法找到或不能接收的网络名称。';
ERROR_BAD_PROFILE: SError := '头文件的格式不正确。';
ERROR_BAD_PROVIDER: SError := '指定的网络供应者匹配错误。';
ERROR_BUSY: SError := '网络可能正在初始化,你需要重新登录。';
ERROR_CANCELLED: SError := '连接被网络供应者取消了。';
ERROR_CANNOT_OPEN_PROFILE: SError := '系统无法打开网络连接的头文件。';
ERROR_DEVICE_ALREADY_REMEMBERED: SError := '指定的逻辑设备入口错误。';
ERROR_EXTENDED_ERROR: SError := '发生了特殊的网络错误。';
ERROR_INVALID_PASSWORD: SError := '输入的密码是非法的。';
ERROR_NO_NET_OR_BAD_PATH: SError := '网络不通或者错误路径。';
ERROR_NO_NETWORK: SError := '网络根本不存在。';
259: SError := '用户名无效,服务器不接受该用户名。';
end;
Label1.Caption := SError;
end;
FreeMem(RName, 20);
FreeMem(CName, 20);
FreeMem(CPass, 20);
end;
procedure TLogForm.CheckBox1Click(Sender: TObject);
begin
SName.ReadOnly := CheckBox1.Checked;
if CheckBox1.Checked then begin
SName.Text := 'GUEST';
SName.Color := clSilver;
SPass.Text := '';
end else SName.Color := clWindow;
end;
procedure TLogForm.FormActivate(Sender: TObject);
begin
WNetCancelConnection2('DFNO0', 0, TRUE);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -