delphi的问题高手帮忙,望求正解
varForm1:TForm1;name:string;code:string;implementationusesUnit2;{$R*.dfm}procedureTFo...
var
Form1: TForm1;
name:string;
code:string;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if(name=null or code=null)then
showmessage('请先注册一个用户')
else
if(edit1.text=name and edit2.text=code) then//这行出错
showmessage('登陆成功')
else
showmessage('用户名或密码错误');
end;
出错提示
[Error] Unit1.pas(50): Operator not applicable to this operand type
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'
这是form1
下面是form2
var
Form2: TForm2;
name:string;
code:string;
implementation
{$R *.dfm}
begin
name:=form2.edit1.text;
code:=form2.edit2.text;
end. 展开
Form1: TForm1;
name:string;
code:string;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if(name=null or code=null)then
showmessage('请先注册一个用户')
else
if(edit1.text=name and edit2.text=code) then//这行出错
showmessage('登陆成功')
else
showmessage('用户名或密码错误');
end;
出错提示
[Error] Unit1.pas(50): Operator not applicable to this operand type
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'
这是form1
下面是form2
var
Form2: TForm2;
name:string;
code:string;
implementation
{$R *.dfm}
begin
name:=form2.edit1.text;
code:=form2.edit2.text;
end. 展开
3个回答
展开全部
1.关机代码:
procedure TForm1.FormCreate(Sender: TObject);
var
hToken : THandle;
Tkp : TTokenPrivileges;
Zero:DWORD;
begin
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken);
LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);
Tkp.PrivilegeCount :=1;
Tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,False,Tkp,SizeOf(TTokenPrivileges),nil,Zero);
end;
procedure TForm1.btnOKClick(Sender: TObject);
begin
if self.RadioButton1.Checked then
begin
ExitWindowsEx(EWX_LOGOFF,0);
end;
if self.RadioButton2.Checked then
begin
ExitWindowsEx(EWX_REBOOT,0);
end;
if self.RadioButton3.Checked then
begin
ExitWindowsEx(EWX_SHUTDOWN or EWX_POWEROFF,0);
end;
end;
2.
让Form2显示
var
Form2:TForm;
begin
Form2:=TForm.Create(Application);
Form2.Position:=poDesktopCenter; //加上这个
Form2.width:=347;//加上这个
Form2.Height:=240;//加上这个
Form2.Show;
end;
3.
隐藏运行目录下批处理文件.
使用Winexec('xxx.bat',0); //隐藏运行目录下的xxx.bat
procedure TForm1.FormCreate(Sender: TObject);
var
hToken : THandle;
Tkp : TTokenPrivileges;
Zero:DWORD;
begin
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken);
LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);
Tkp.PrivilegeCount :=1;
Tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,False,Tkp,SizeOf(TTokenPrivileges),nil,Zero);
end;
procedure TForm1.btnOKClick(Sender: TObject);
begin
if self.RadioButton1.Checked then
begin
ExitWindowsEx(EWX_LOGOFF,0);
end;
if self.RadioButton2.Checked then
begin
ExitWindowsEx(EWX_REBOOT,0);
end;
if self.RadioButton3.Checked then
begin
ExitWindowsEx(EWX_SHUTDOWN or EWX_POWEROFF,0);
end;
end;
2.
让Form2显示
var
Form2:TForm;
begin
Form2:=TForm.Create(Application);
Form2.Position:=poDesktopCenter; //加上这个
Form2.width:=347;//加上这个
Form2.Height:=240;//加上这个
Form2.Show;
end;
3.
隐藏运行目录下批处理文件.
使用Winexec('xxx.bat',0); //隐藏运行目录下的xxx.bat
展开全部
语法有待提高
if(length(name)=0) or (Length(code)=0)then
...
if(length(name)=0) or (Length(code)=0)then
...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
if(edit1.text=name and edit2.text=code) then//
改一下,
if(edit1.text=name) and (edit2.text=code) then//
程序第一句也要改一下
if(name='') or (code='')then
showmessage('请先注册一个用户')
else
if(edit1.text=name) and (edit2.text=code) then//这行出错
showmessage('登陆成功')
else
showmessage('用户名或密码错误');
end;
改一下,
if(edit1.text=name) and (edit2.text=code) then//
程序第一句也要改一下
if(name='') or (code='')then
showmessage('请先注册一个用户')
else
if(edit1.text=name) and (edit2.text=code) then//这行出错
showmessage('登陆成功')
else
showmessage('用户名或密码错误');
end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询