📄 main.pas
字号:
wSocket.Multicast := true;
wSocket.Proto := 'udp';
wSocket.Addr := '225.1.2.3'; // or whatever you decide
wSocket.Port := '12345'; // or whatever you decide
wSocket.Connect();
end;
if s_guangbo = true then
begin
pingmu_state := '屏幕广播';
PingmuTimer.Interval := fabaotime;
form1.Hide; //主界面最小化
LMDTrayIcon1.PopUpMenu := nil;
priscreen := Tbitmap.Create;
priscreen.Width := screen.Width;
priscreen.Height := screen.Height;
priscreen.Canvas.brush.Color := clBlack;
priscreen.Canvas.FillRect(rect(0, 0, screen.width, screen.height));
// priscreen.SaveToFile('c:\wsh.bmp');
//初始化上一此屏幕流
//判断发送的类型
if not draw_mouse then // 判断是否发送鼠标状态
sendstate := sendstate + 'nomouse';
if xieyi = 0 then //判断是否TCP协议
sendstate := sendstate + 'tcp'
else
sendstate := sendstate + 'ipx';
if (send_voice) and (waveoutgetvolume(0, @v) = 0) then //判断是否发送语音
sendstate := sendstate + 'sendvoice'
else send_voice := false;
case compress_mode of
1: sendstate := sendstate + 'zip'; //用ZIP压缩
2: sendstate := sendstate + 'lzrw'; //用LZRW压缩
end;
for i := 0 to student_count - 1 do
begin
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
begin
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + sendstate);
sleep(1);
end;
end;
sleep(500);
if xieyi = 0 then
begin
if wsockethook.State <> wsclosed then Wsockethook.Close;
// 打开自己的UDP协议,发送数据
Wsockethook.MultiCast := true;
WSockethook.Proto := 'udp';
WSockethook.Addr := '225.1.2.4';
WSockethook.Port := '999';
// WSockethook.LocalPort := '7516';
WSockethook.Connect;
if wsocketsize.State <> wsclosed then Wsocketsize.Close;
// 打开自己的UDP协议,发送数据
Wsocketsize.MultiCast := true;
WSocketsize.Proto := 'udp';
WSocketsize.Addr := '225.1.2.5';
WSocketsize.Port := '518';
// WSocketsize.LocalPort := '7518';
WSocketsize.Connect;
// wsocketsize.SendStr('12345');
end;
if not draw_mouse then
begin
msg_id := RegisterWindowMessage(STR_MSGMOUSEPOS);
EnableMouseHook(handle); //获取鼠标位置
end;
//是否启动语音传输
if send_voice then
begin
if acmMetrics(nil, ACM_METRIC_MAX_SIZE_FORMAT, FMaxFmtSize) <> 0 then begin
showmessage('Error getting the max compression format size.');
Exit;
end;
GetMem(Format, FMaxFmtSize);
if Format = nil then begin
showmessage('Error allocating local memory for WaveFormatEx structure.');
Exit;
end;
// initialize the format to standard PCM...
FillChar(Format^, FMaxFmtSize, 0);
Format.wFormatTag := WAVE_FORMAT_PCM;
Format.nChannels := 1;
Format.nSamplesPerSec := 11025;
Format.nAvgBytesPerSec := 11025;
Format.nBlockAlign := 1;
Format.wBitsPerSample := 8;
Format.cbSize := 0;
SVoicesocket.Close;
// 打开自己的UDP协议,发送语音数据
SVoiceSocket.MultiCast := true;
SVoiceSocket.Proto := 'udp';
SVoiceSocket.Addr := '225.1.2.6';
SVoiceSocket.Port := '666';
// SVoiceSocket.LocalPort := '7517';
SVoiceSocket.Connect;
SoundIN1.Open(format); //打开语音输入
sendwav := Tmemorystream.Create;
sendwav.Clear;
// PingmuTimer.Synchronize := true; //启动多线程
// PingmuTimer.UseThread := true;
end;
// showmessage(inttostr(huandeng));
if Huandeng = 0 then
begin
LMDGlobalHotKey2.Active := false;
PingmuTimer.Enabled := true; //启动连续广播
timer2.Enabled:=true;
end
else
begin
LMDGlobalHotKey2.Active := true;
PingmuTimerTimer(sender);
end;
//鼠标广播:
end
else
begin //否则关闭广播...
PingmuTimer.Enabled := false;
for i := 0 to student_count - 1 do
begin
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '停止广播');
end;
s_Guangbo := false;
if xieyi = 0 then
begin
Wsocket.Close; //关闭UDP协议
WSockethook.close;
wsocketsize.close;
end
else
begin
ipx1.Close;
ipx2.close;
end;
end;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
if (ListView1.SelCount <> 1) or (listview1.Selected.ImageIndex = 0) then
begin
//showmessage('只能选择一个学生或此学生没有连接!');
rxlabel1.Caption :=' 只能选择一个学生或此学生没有连接!';
exit;
end;
rxlabel1.Caption:=school_name+' 班级: '+class_name+' 授课教师: '+teacher_name+' 课程: '+course_name;
LMDGlobalHotKey2.Active := false;
//取得发送数据延时
//发送信息给学生机,打开UDP协议
s_selected := listview1.Selected.Index;
wsh_socket[s_selected].SendStr('/*csh*/:' + #13 + #10 + '遥控辅导' + inttostr(student_time));
//初试化流
bmpstream.free; //释放内存流
drawstream.free;
bmpstream := Tmemorystream.Create;
bmpstream.Clear;
drawstream := TmemoryStream.Create;
drawstream.Clear;
//打开UDP协议
//FServerAddr := WSocketResolveHost(ServerEdit.Text);
if wsocket.State <> wsclosed then wsocket.close;
wSocket.Proto := 'udp';
wSocket.Addr := '0.0.0.0';
wSocket.MultiCast := true;
wSocket.ReuseAddr := true;
wSocket.Port := '12345'; // or whatever
wSocket.MultiCastAddrStr := '225.1.2.3'; // or whatever
wSocket.Listen();
if wsocketsize.State <> wsclosed then WSocketsize.Close;
WSocketsize.Proto := 'udp';
WSocketsize.Addr := '0.0.0.0';
WSocketsize.MultiCast := true;
WSocketsize.ReuseAddr := true;
WSocketsize.Port := '518';
WSocketsize.MultiCastAddrStr := '225.1.2.5';
WSocketsize.Listen;
if wsockethook.State <> wsclosed then Wsockethook.Close;
// 打开自己的UDP协议,发送数据
Wsockethook.MultiCast := true;
WSockethook.Proto := 'udp';
WSockethook.Addr := '225.1.2.4';
WSockethook.Port := '999';
// WSockethook.LocalPort := '7516';
WSockethook.Connect;
priscreen := Tbitmap.Create;
priscreen.Width := screen.Width;
priscreen.Height := screen.Height;
jguangbof.Left := 0;
jguangbof.Top := 0;
jguangbof.Width := screen.Width;
jguangbof.Height := screen.height;
jguangbof.Label1.Caption := listview1.Selected.Caption + '遥控辅导...按(Shift+F11)关闭!';
jguangbof.Label1.Left := screen.width - jguangbof.Label1.width;
jguangbof.Label1.top := 0;
jGuangbof.Show;
pingmu_state := '遥控辅导';
// guangbof.Label1.Visible := false;
// guangbof.DXDraw1.Visible:=true;
jguangbof.DXTimer1.Enabled := true;
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
var
i: smallint;
Format: PWAVEFORMATEX;
FMaxFmtSize: DWORD;
begin
if acmMetrics(nil, ACM_METRIC_MAX_SIZE_FORMAT, FMaxFmtSize) <> 0 then begin
showmessage('Error getting the max compression format size.');
Exit;
end;
GetMem(Format, FMaxFmtSize);
if Format = nil then begin
showmessage('Error allocating local memory for WaveFormatEx structure.');
Exit;
end;
// initialize the format to standard PCM...
FillChar(Format^, FMaxFmtSize, 0);
Format.wFormatTag := WAVE_FORMAT_PCM;
Format.nChannels := 2;
Format.nSamplesPerSec := 44100;
Format.nAvgBytesPerSec := 176400;
Format.nBlockAlign := 4;
Format.wBitsPerSample := 16;
Format.cbSize := 0;
for i := 0 to student_count - 1 do
begin
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '语音广播');
end;
//Form1.Hide;
//showmessage('点击[OK]按钮开始语音广播!');
if svoiceSocket.State <> wsclosed then SVoicesocket.Close;
// 打开自己的UDP协议,发送语音数据
SVoiceSocket.MultiCast := true;
SVoiceSocket.Proto := 'udp';
SVoiceSocket.Addr := '225.1.2.6';
SVoiceSocket.Port := '666';
// SVoiceSocket.LocalPort := '7517';
SVoiceSocket.Connect;
SoundIN1.Open(format); //打开语音输入
sendwav := Tmemorystream.Create;
sendwav.Clear;
LMDTrayIcon1.Active := true;
LMDTrayIcon1.Hint := '语音广播(注意:双击图标结束广播)';
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
if (ListView1.SelCount <> 1) or (listview1.Selected.ImageIndex = 0) then
begin
//showmessage('只能选择一个学生或此学生没有连接');
rxlabel1.Caption :='只能选择一个学生或此学生没有连接!';
exit;
end;
rxlabel1.Caption:=school_name+' 班级: '+class_name+' 授课教师: '+teacher_name+' 课程: '+course_name;
form1.hide;
duijiang.show;
end;
procedure TForm1.SpeedButton5Click(Sender: TObject);
var
messagef: Tmessagef;
begin
if ListView1.SelCount < 1 then
begin
//showmessage('没有选定任何学生!');
rxlabel1.Caption :='请选定接需要收网上通知的学生!';
exit;
end;
rxlabel1.Caption:=school_name+' 班级: '+class_name+' 授课教师: '+teacher_name+' 课程: '+course_name;
//N1Click(sender); 由于刷新速度太慢
Messagef := TMessagef.create(self);
Messagef.showmodal;
end;
procedure TForm1.SpeedButton6Click(Sender: TObject);
var
TaoLunf: TTaolunf;
i: smallint;
Format: PWAVEFORMATEX;
FMaxFmtSize: DWORD;
begin
if ListView1.SelCount < 1 then
begin
//showmessage('请选择一组参加讨论的学生!');
rxlabel1.Caption :='请选择一组参加讨论的学生!';
exit;
end;
rxlabel1.Caption:=school_name+' 班级: '+class_name+' 授课教师: '+teacher_name+' 课程: '+course_name;
Taolunf := TTaolunf.Create(self);
Taolunf.Memo1.Clear;
Taolunf.Memo1.Lines.Add('教师机:' + s_computername);
for i := 0 to student_count - 1 do
begin
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
Taolunf.Memo1.Lines.Add(student_name[i] + ':>' + computer_name[i]);
end;
for i := 0 to student_count - 1 do
begin
if (ListView1.Items[i].imageindex <> 0) and (listView1.Items[i].Selected = true) then
begin
wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '分组讨论' + Taolunf.Memo1.Lines.Text);
sleep(1);
end;
end;
//语音对讲
if acmMetrics(nil, ACM_METRIC_MAX_SIZE_FORMAT, FMaxFmtSize) <> 0 then begin
showmessage('Error getting the max compression format size.');
Exit;
end;
GetMem(Format, FMaxFmtSize);
if Format = nil then begin
showmessage('Error allocating local memory for WaveFormatEx structure.');
Exit;
end;
// initialize the format to standard PCM...
FillChar(Format^, FMaxFmtSize, 0);
Format.wFormatTag := WAVE_FORMAT_PCM;
Format.nChannels := 1;
Format.nSamplesPerSec := 11025;
Format.nAvgBytesPerSec := 11025;
Format.nBlockAlign := 1;
Format.wBitsPerSample := 8;
Format.cbSize := 0;
if svoiceSocket.State <> wsclosed then SVoicesocket.Close;
// 打开自己的UDP协议,发送语音数据
SVoiceSocket.MultiCast := true;
SVoiceSocket.Proto := 'udp';
SVoiceSocket.Addr := '225.1.2.6';
SVoiceSocket.Port := '666';
// SVoiceSocket.LocalPort := '7517';
SVoiceSocket.Connect;
if RVoiceSocket.State <> wsclosed then Rvoicesocket.Close;
RVoiceSocket.Proto := 'udp';
RVoiceSocket.Addr := '0.0.0.0';
RVoiceSocket.MultiCast := true;
RVoiceSocket.ReuseAddr := true;
RVoiceSocket.Port := '777';
RVoiceSocket.MultiCastAddrStr := '225.1.2.7';
RVoiceSocket.Listen;
SoundIN1.Open(format); //打开语音输入
SoundOUt1.Open(format); //打开语音输出
sendwav := Tmemorystream.Create;
sendwav.Clear;
voice_wsh := Tmemorystream.create;
voice_wsh.Clear;
Taolunf.showmodal;
end;
procedure TForm1.SpeedButton7Click(Sender: TObject);
var
Lockf: TLockf;
begin
if ListView1.SelCount < 1 then
begin
//showmessage('没有选择任何学生!');
rxlabel1.Caption :='请选择需要被锁定学生机!';
exit;
end;
rxlabel1.Caption:=school_name+' 班级: '+class_name+' 授课教师: '+teacher_name+' 课程: '+course_name;
Lockf := Tlockf.Create(self);
Lockf.ShowModal;
end;
procedure TForm1.SpeedButton8Click(Sender: TObject);
var
i: smallint;
begin
if ListView1.SelCount < 1 then
begin
//showmessage('没有选择任何学生!');
rxlabel1.Caption :='请选择需要解锁的学生机!';
exit;
end;
rxlabel1.Caption:=school_name+' 班级: '+class_name+' 授课教师: '+teacher_name+' 课程: '+course_name;
if
(Application.MESSAGEBOX('是否要给学生机解锁!', '提示信息',
MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION) = IDYES)
then
begin
for i := 0 to stud
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -