qq_33490048 2017-08-02 01:55 采纳率: 0%
浏览 984

有没有大牛能把下面的delphi代码转成java啊,如果顺便能稍微解释一下就更好了!万分感谢!

procedure TfmMain.SbtnSet1Click(Sender: TObject);
var
dwPort : Integer;
dwValue : Integer;
dwLocalPort : Integer;
Buffer : PChar;
BufLen : DWORD;
HostName : string;
strFileName : string;

FileName, strFilePath : string;
IniFile: TIniFile;

begin
lvGroups.Items.Clear;
mmoUnAssigned.Clear;
mmoWirelessStatus.Clear;
mmoBlacklistInfo.Clear;
mmoAgentStateChanged.Clear;

dwPort := 0;
dwLocalPort := 0;

BufLen := 255;
GetMem(Buffer, BufLen);
GetComputerName(Buffer, BufLen);
HostName := string(Buffer);

if edtAddr.Text = '' then
begin
MessageDlg('请输入CDMS服务器地址!',mtWarning,[mbOk],0);
edtAddr.SetFocus;
Exit;
end;

if edtPort.Text <> '' then
begin
if IsDigit(edtPort.Text) then
begin
dwPort := Str2DWord(edtPort.Text);
if (dwPort = 0) then
begin
MessageDlg('CDMS服务器端口不能为0,请重新输入!',mtWarning,[mbOk],0);
edtPort.SetFocus;
Exit;
end;
end
else
begin
ShowMessage('CDMS服务器端口值只能是数字,请重新输入!');
edtPort.SetFocus;
Exit;
end;
end
else
begin
Application.MessageBox('请输入CDMS服务器端口信息!', '错误', MB_OK);
edtPort.SetFocus;
Exit;
end;

if edtLocal.Text <> '' then
begin
if IsDigit(edtLocal.Text) then
begin
dwLocalPort := Str2DWord(edtLocal.Text);
if (dwLocalPort = 0) then
begin
MessageDlg('本地端口不能为0,请重新输入!',mtWarning,[mbOk],0);
edtLocal.SetFocus;
Exit;
end;
end
else
begin
ShowMessage('本地端口值只能是数字,请重新输入!');
edtLocal.SetFocus;
Exit;
end;
end
else
begin
Application.MessageBox('请输入本地端口信息!', '错误', MB_OK);
edtLocal.SetFocus;
Exit;
end;

if LowerCase(edtCdmsAddr.Text) = LowerCase(HostName) then
begin
if edtPort.Text = edtLocal.Text then
begin
MessageDlg('CDMS的端口号和本地端口号不能相同,请重新输入!',mtWarning,[mbOk],0);
edtLocal.SetFocus;
Exit;
end;
end;

if edtAgentId.Text <> '' then
begin
if IsDigit(edtAgentId.Text) then
begin
dwValue := Str2DWord(edtAgentId.Text);
if (dwvalue = 0) then
begin
MessageDlg('座席标识不能为0,请重新输入!',mtWarning,[mbOk],0);
edtAgentId.SetFocus;
Exit;
end;
end
else
begin
ShowMessage('座席标识只能是数字,请重新输入!');
edtAgentId.SetFocus;
Exit;
end;
end
else
begin
Application.MessageBox('请输入座席标识信息!', '错误', MB_OK);
edtAgentId.SetFocus;
Exit;
end;

if edtExtension.Text <> '' then
begin
if IsDigit(edtExtension.Text) then
begin
dwValue := Str2DWord(edtExtension.Text);
if (dwvalue = 0) then
begin
MessageDlg('座席话机号码不能为0,请重新输入!',mtWarning,[mbOk],0);
edtExtension.SetFocus;
Exit;
end;
end
else
begin
ShowMessage('座席话机号码只能是数字,请重新输入!');
edtExtension.SetFocus;
Exit;
end;
end
else
begin
Application.MessageBox('请输入座席话机号码信息!', '错误', MB_OK);
edtExtension.SetFocus;
Exit;
end;

if edtPassword.Text = '' then
begin
MessageDlg('请输入座席登录口令!',mtWarning,[mbOk],0);
edtPassword.SetFocus;
Exit;
end;

Inc(dwTestCount);

if bAgentLogon then
begin
if (dwTestCount mod 2) = 0 then
// SendAgentLogoffRequest();

Self.agntsftphn1.ServerName := '';
Self.agntsftphn1.ServerPort := 0;
Self.agntsftphn1.LocalPort := 0;

Sleep(1000);

bAgentLogon := FALSE;

end;

strAgentId := edtAgentId.Text;
strPassword := edtPassword.Text;
strExtension := edtExtension.Text;
Self.agntsftphn1.AgentID := edtAgentId.Text;
Self.agntsftphn1.AgentPassword := edtPassword.Text;
Self.agntsftphn1.Extension := edtExtension.Text;;

Self.agntsftphn1.ServerName := edtAddr.Text;
Self.agntsftphn1.ServerPort := dwPort;
Self.agntsftphn1.LocalPort := dwLocalPort;

sbtnRequest.Enabled := TRUE;

FileName := ExtractFilePath(Application.ExeName) + 'IniFile\CdmsInfoCfg.ini';
try
IniFile := TIniFile.Create(FileName);
IniFile.WriteString('AgentParam', 'ServerAddr', edtAddr.Text);
IniFile.WriteString('AgentParam', 'ServerPort', edtPort.Text);
IniFile.WriteString('AgentParam', 'LocalPort', edtLocalPort.Text);
IniFile.WriteString('AgentParam', 'AgentID', edtAgentId.Text);
IniFile.WriteString('AgentParam', 'AgentStaNum', edtExtension.Text);
IniFile.WriteString('AgentParam', 'AgentPW', edtPassword.Text);
finally
IniFile.Free;
end;

sbStatus.Panels.Items[1].Text := '座席标识:' + strAgentId;
sbStatus.Panels.Items[3].Text := '分机号码:' + strExtension;
sbStatus.Panels.Items[4].Text := '分机状态:' + '未知';
end;

  • 写回答

1条回答 默认 最新

  • 乔小南丶 2017-08-02 02:12
    关注

    6666 666666坐等大神

    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊