📄 main.pas
字号:
sendstate := sendstate + 'ipx';
if send_voice then //判断是否发送语音
sendstate := sendstate + 'sendvoice';
case compress_mode of
1: sendstate := sendstate + 'zip'; //用ZIP压缩
2: sendstate := sendstate + 'lzrw'; //用LZRW压缩
end;
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + sendstate);
quan_screen := true; //发送一个全屏幕
PingmuTImer.Enabled := true;
end;
end;
end;
end;
procedure TForm1.WSocket1DataAvailable(Sender: TObject; Error: Word);
var
s_receive: string;
s_command, s_message, s_name: string;
i: smallint;
jingchengf: Tjingchengf;
buf: array[0..bufsize - 1] of char;
begin
if wsh_pingmu then //当传输屏幕时打开
begin
if LeftSize > BufSize then RecSize := BufSize
else RecSize := LeftSize;
wsh_socket[s_selected].receive(@buf, RecSize);
LeftSize := LeftSize - RecSize;
TmpStream.WriteBuffer(buf, RecSize);
if leftSize < BufSize then //读完数据
begin
wsh_pingmu := false;
TmpStream.Position := 0;
pingmu_ok := true;
end
else
wsh_socket[s_selected].SendStr('/*csh*/:' + #13 + #10 + '开始监看');
exit;
end;
s_receive := (sender as Twsocket).receivestr;
s_command := copy(s_receive, 11, length(s_receive) - 10); //取得命令
if s_receive = '' then
begin
// StatusLine.Panels[1].Text:='尚未登陆...';
exit;
end;
if copy(s_receive, 1, 10) = '/*csh*/:' + #13 + #10 then
begin
if copy(s_command, 1, 8) = '电子举手' then //第一种信息
begin
s_name := copy(s_receive, 19, length(s_receive) - 18);
for i := 0 to student_count - 1 do
begin
if computer_ip[i] = '' then continue;
// showmessage(trim(computer_IP[i])+' '+trim(s_name)+' '+inttostr(student_count));
sleep(1);
if comparestr(trim(computer_IP[i]), trim(s_name)) = 0 then
// if trim(computer_IP[i]) = trim(s_name) then
begin
if zhuce = true then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '举手注册')
else
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '举手未注');
if ListView1.Items[i].imageindex = 1 then
ListView1.Items[i].imageindex := 3;
break;
end;
end;
exit;
end;
if copy(s_command, 1, 8) = '查看进程' then // 第二钟信息
begin
s_message := copy(s_receive, 19, length(s_receive) - 18);
jingchengf := Tjingchengf.create(self);
jingchengf.ListBox1.Items.Text := s_message;
jingchengf.showmodal;
// showmessage(s_message);
exit;
end;
if copy(s_command, 1, 8) = '屏幕监看' then //第三钟信息
begin
wsh_pingmu := true;
TmpStream := TMemoryStream.Create;
TmpStream.Clear;
pingmu_size := strtoint(copy(s_command, 9, length(s_command) - 8));
leftsize := pingmu_size;
sleep(1);
wsh_socket[s_selected].SendStr('/*csh*/:' + #13 + #10 + '开始监看');
exit;
end;
if copy(s_command, 1, 8) = '定时锁定' then //第四钟信息
begin
s_name := copy(s_receive, 19, length(s_receive) - 18);
for i := 0 to student_count - 1 do
begin
if uppercase(trim(computer_name[i])) = uppercase(trim(s_name)) then
begin
ListView1.Items[i].imageindex := 2;
break;
end;
end;
exit;
end;
if copy(s_command, 1, 8) = '屏幕长度' then //第五钟信息
begin
send_streamsize := strtoint(copy(s_receive, 19, length(s_receive) - 18));
exit;
end;
end;
end;
procedure TForm1.N13Click(Sender: TObject);
var
i: smallint;
begin
n1.enabled := false;
n13.Enabled := false;
n15.Enabled := false;
for i := 0 to student_count - 1 do
begin
if (Listview1.Items[i].imageindex <= 1) and (computer_ip[i] <> '') then
begin
wsh_socket[i].Close;
Listview1.Items[i].imageindex := 0;
Wsh_Socket[i].Addr := computer_ip[i];
// showmessage( computer_ip[i]);
Wsh_Socket[i].Port := WSHPort;
Wsh_Socket[i].Proto := 'tcp';
try
Wsh_Socket[i].Connect;
except
showmessage('刷新到第(' + inttostr(i + 1) + ')台计算机出错!' + #13 + #10 + '1、没有安装TCP/IP协议' + #13 + #10 +
'2、与教师机的IP地址不同类!' +
#13 + #10 + '3、没有设置为指定IP地址:' + #13 + #10 +
'例如:192.168.100.1 255.255.255.0');
break;
end;
end;
if (Listview1.Items[i].imageindex > 1) or
(Wsh_Socket[i].State in [wsConnecting]) then continue;
end;
n1.enabled := true;
n15.Enabled := true;
n13.Enabled := true;
end;
procedure TForm1.N15Click(Sender: TObject);
var
inifilename: string;
inifile: Tinifile;
begin
if n48.Checked then
begin
inifilename := ExtractFilePath(Application.EXEName) + 'teacher.ini';
inifile := Tinifile.create(inifilename);
inifile.writestring('CLASS', 'autologin', '0');
inifile.free;
LWSocket.Close;
end
else
begin
//写配置文件
inifilename := ExtractFilePath(Application.EXEName) + 'teacher.ini';
inifile := Tinifile.create(inifilename);
inifile.writestring('CLASS', 'autologin', '1');
inifile.free;
if LWSocket.State <> wsclosed then LWSocket.close;
LWSocket.Proto := 'udp';
LWSocket.Addr := '0.0.0.0';
LWSocket.MultiCast := true;
LWSocket.ReuseAddr := true;
LWSocket.Port := '1525';
LWSocket.MultiCastAddrStr := '225.1.2.8'; // or whatever
LWSocket.Listen;
end;
n48.Checked := not n48.Checked;
end;
procedure TForm1.N17Click(Sender: TObject);
var
i, j, k: smallint;
begin
for i := 0 to student_count - 1 do
begin
j := i + 1;
for k := j to student_count - 1 do
begin
if computer_name[i] = computer_name[k] then
showmessage(inttostr(i + 1) + '与' + inttostr(k + 1) + '的计算机名称相同!');
end;
end;
showmessage('没有再发现计算机名相同!');
end;
procedure TForm1.N24Click(Sender: TObject);
begin
// close;
form1.show;
end;
procedure TForm1.N25Click(Sender: TObject);
var
inifile: Tinifile;
inifilename: string;
i: smallint;
begin
//写文件
inifilename := ExtractFilePath(Application.EXEName) + 'teacher.ini';
inifile := Tinifile.create(inifilename);
for i := 0 to student_count - 1 do
begin
inifile.writestring('STUDENT', 'computer' + inttostr(i + 1), computer_name[i]);
inifile.writestring('STUDENT', 'IP' + inttostr(i + 1), computer_ip[i]);
inifile.writestring('STUDENT', 'student' + inttostr(i + 1), student_name[i]);
inifile.writestring('STUDENT', 'memo' + inttostr(i + 1), student_memo[i]);
end;
inifile.Free;
showmessage('所有学生的信息保存完成!');
end;
procedure TForm1.N29Click(Sender: TObject);
var
i: smallint;
begin
if ListView1.SelCount < 1 then
begin
showmessage('没有选择任何学生!');
exit;
end;
for i := 0 to student_count - 1 do
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '关闭会议');
end;
procedure TForm1.N27Click(Sender: TObject);
var
i: smallint;
netmeeting_ok: boolean;
HCurrentWindow: Hwnd;
szText: array[0..254] of char;
begin
netmeeting_ok := false;
if ListView1.SelCount < 1 then
begin
showmessage('没有选择任何学生!');
exit;
end;
//检测是否已经运行NETMEETING
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255) > 0 then
if pos('NetMeeting', strpas(@szText)) > 0 then
begin
netmeeting_ok := true;
break;
end;
hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
if netmeeting_ok = false then
begin
showmessage('请先运行本机的NetMeeting,并设置为自动接收呼叫!');
exit;
end;
for i := 0 to student_count - 1 do
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '呼叫会议' + s_computername);
end;
procedure TForm1.N18Click(Sender: TObject);
var
s_path, s_inifile, s_localip: string;
w_path: array[0..50] of char;
i: smallint;
inifile: Tinifile;
begin
//写Aftpsrv.ini文件
s_inifile := ExtractFilePath(Application.EXEName) + 'ftp\aftpsrv.ini';
IniFile := TIniFile.Create(s_IniFile);
IniFile.WriteInteger('CLASS', 'StudentCount', student_count);
for i := 0 to student_count - 1 do
begin
IniFile.WriteString('STUDENT', 'Student' + inttostr(i + 1), student_name[i]);
IniFile.WriteString('STUDENT', 'IP' + inttostr(i + 1), computer_ip[i]);
end;
IniFile.free;
//执行文件传输服务程序
s_path := ExtractFilePath(Application.EXEName) + 'ftp\ftpsrv.exe';
strpcopy(w_path, s_path);
ShellExecute(handle, 'open', w_path, nil, nil, SW_ShowNormal);
//发送学生执行文件传输客户端的程序
s_localip := LocalIpList.Text;
for i := 0 to student_count - 1 do
if ListView1.Items[i].imageindex <> 0 then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '文件传输' + s_localip);
end;
procedure TForm1.N28Click(Sender: TObject);
var
i: smallint;
begin
if ListView1.SelCount < 1 then
begin
showmessage('没有选择任何学生!');
exit;
end;
for i := 0 to student_count - 1 do
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '桌面锁定');
showmessage('桌面锁定完成!');
end;
procedure TForm1.N30Click(Sender: TObject);
var
i: smallint;
begin
if ListView1.SelCount < 1 then
begin
showmessage('没有选择任何学生!');
exit;
end;
for i := 0 to student_count - 1 do
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '桌面解锁');
showmessage('桌面解锁完成!');
end;
procedure TForm1.N32Click(Sender: TObject);
var
i: smallint;
begin
if ListView1.SelCount < 1 then
begin
showmessage('没有选择任何学生!');
exit;
end;
for i := 0 to student_count - 1 do
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '全屏广播');
showmessage('全屏显示共享的程序完成!');
end;
procedure TForm1.N33Click(Sender: TObject);
var
i: smallint;
begin
if ListView1.SelCount < 1 then
begin
showmessage('没有选择任何学生!');
exit;
end;
for i := 0 to student_count - 1 do
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '关闭话筒');
if copy(n33.caption, 1, 12) = '关闭学生话筒' then
begin
n33.caption := '打开学生话筒';
showmessage('关闭学生话筒完成!');
end
else
begin
n33.caption := '关闭学生话筒';
showmessage('打开学生话筒完成!');
end;
end;
procedure TForm1.N6404801Click(Sender: TObject);
var
i: smallint;
begin
if ListView1.SelCount < 1 then
begin
showmessage('没有选择任何学生!');
exit;
end;
for i := 0 to student_count - 1 do
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '640*480');
showmessage('学生机640*480屏幕设置完成!');
end;
procedure TForm1.N8006001Click(Sender: TObject);
var
i: smallint;
begin
if ListView1.SelCount < 1 then
begin
showmessage('没有选择任何学生!');
exit;
end;
for i := 0 to student_count - 1 do
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '800*600');
showmessage('学生屏幕800*600完成!');
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -