procedure TServerForm.EnableButs; var b : boolean; begin b := ServerSocket1.Active;
StartBut.Enabled := not b; PortEdit.Enabled := not b; DisconBut.Enabled := b; // MinimizeBut.Enabled := b; end;
procedure TServerForm.GetHostNameAddr; var buf : array[0..MAX_PATH] of char; he : PHostEnt; buf2 : PChar; rc : integer; begin rc := GetHostName(buf, sizeof(buf));
if rc<>SOCKET_ERROR then begin he := GetHostByName(buf); if he = nil then begin rc := WSAGetLastError; NameLabel.Caption := Format('Socket Error %d = %s', [rc, SysErrorMessage(rc)]); end else begin buf2 := inet_ntoa(PInAddr(he.h_addr^)^); NameLabel.Caption := Format('%s (%s)', [buf, buf2]); end; end else begin NameLabel.Caption := 'Unknown Host'; end; end;
procedure TServerForm.FormShow(Sender: TObject); begin EnableButs; GetHostNameAddr; end;
procedure TServerForm.MinimizeButClick(Sender: TObject); begin if ServerSocket1.Active then begin TrayIcon1.ToolTip := Application.Title + ' - Port: ' + PortEdit.Text; end else begin TrayIcon1.ToolTip := Application.Title + ' - Inactive'; end;