⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 这是一个非常好的教师和学生沟通用的电子教室!
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      begin
        bmpstream.Clear;
        bmpstream.Free
      end;
      exit;
    end;

    if s_command = '开始监看' then //多次发送
    begin
      if LeftSize > BufSize then SendSize := BufSize
      else SendSize := LeftSize;
      buf := #0;
      BmpStream.ReadBuffer(Buf, SendSize);
      LeftSize := LeftSize - SendSize;
      if LeftSize = 0 then
      begin
        BmpStream.Clear; { 清空流 }
        BmpStream.Free;
        exit;
      end;
      Clisocket.Send(@buf, SendSize); { 将数据发到主控机 }
      exit;
    end;

    if s_command = '结束监看' then
    begin
      leftsize := 0;
    end;

    if copy(s_command, 1, 8) = '举手注册' then
    begin
      SetForeGroundWindow(form1.handle);
      Jushouf := TJushouf.Create(self);
      Jushouf.show;
      exit;
    end;

    if copy(s_command, 1, 8) = '举手未注' then
    begin
      SetForeGroundWindow(form1.handle);
      s_zhuce := '电子举手成功!(未注册)';
      if copy(s_zhuce, 16, 2) <> '未' then s_zhuce := '';
      Application.MessageBox(pchar(s_zhuce), '未注册', MB_ICONSTOP);
      exit;
    end;

    if copy(s_command, 1, 8) = '分组讨论' 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;

      SoundOut1.Open(format);
      SoundIn1.Open(format); //打开输入
      voice_wsh := Tmemorystream.Create;
      voice_wsh.Position := 0;
      sendwav := Tmemorystream.Create;
      sendwav.Position := 0;

      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);

      Rvoicesocket.Close;
      RVoiceSocket.Proto := 'udp';
      RVoiceSocket.Addr := '0.0.0.0';
      RVoiceSocket.MultiCast := true;
      RVoiceSocket.ReuseAddr := true;
      RVoiceSocket.Port := '666';
      RVoiceSocket.MultiCastAddrStr := '225.1.2.6';
      RVoiceSocket.Listen;

      SVoiceSocket.Close;
      SVoiceSocket.MultiCast := true;
      SVoiceSocket.Proto := 'udp';
      SVoiceSocket.Addr := '225.1.2.7';
      SVoiceSocket.Port := '777';
      SVoiceSocket.Connect;
      Guangboing := true;

      SetForeGroundWindow(form1.handle);  //设置到最前端
      Taolunf.Memo1.Clear;
      Taolunf.Memo1.Lines.Add(copy(s_receive, 19, length(s_receive) - 18));
      Taolunf.Show;
      exit;
    end;


    if copy(s_command, 1, 8) = '教师公告' then //命令1
    begin
      s_message := copy(s_receive, 19, length(s_receive) - 18);
      Tongzf.FormStyle := fsStayOnTop;
      Tongzf.Show;
      Tongzf.Memo1.Clear;
      Tongzf.Memo1.Lines.Add(s_message);
      Tongzf.Memo1.SetFocus;
      exit;
    end;

    if s_command = '关闭系统' then //命令2
    begin
      Guangboing := false;
      confirmclose := true;
      Clisocket.Close;
      SrvSocket.Close;
      confirmclose := true;
      mouse_event(MOUSEEVENTF_LEFTDOWN, 1, 1, 0, 0);
      mouse_event(MOUSEEVENTF_LEFTUP, 1, 1, 0, 0);
      sleep(5);
      if Win32Platform <> VER_PLATFORM_WIN32_NT then //不是NT
      ShellExecute(handle, 'open', 'RUNDLL32.EXE', 'user.exe,ExitWindows', nil, SW_ShowNormal)
      else
      begin
           SetPrivilege('SeShutdownPrivilege', True);
             if not ExitWindowsEx(EWX_SHUTDOWN + EWX_FORCE, 0) then
               SetPrivilege('SeShutdownPrivilege', False);
      end;

      confirmclose := true;
      close;
      exit;
    end;

    if s_command = '重新启动' then //命令3
    begin
      confirmclose := true;
      Guangboing := false;
      confirmclose := true;
      Clisocket.Close;
      SrvSocket.Close;
      mouse_event(MOUSEEVENTF_LEFTDOWN, 1, 1, 0, 0);
      mouse_event(MOUSEEVENTF_LEFTUP, 1, 1, 0, 0);
      sleep(5);
      if Win32Platform <> VER_PLATFORM_WIN32_NT then //不是NT
      ExitWindowsEx(EWX_REBOOT, 0)
      else
      begin
           SetPrivilege('SeShutdownPrivilege', True);
             if not ExitWindowsEx(EWX_REBOOT + EWX_FORCE, 0) then
               SetPrivilege('SeShutdownPrivilege', False);
      end;

      confirmclose := true;
      close;
      exit;
    end;

    if s_command = '注销系统' then
    begin //恢复学生程序,屏幕广播关闭,网上影院关闭
      if guangbo_state = '屏幕广播' then
      begin
        hua_ok := false;
        Guangboing := false;
        guangbof.DXTimer1.Enabled := false;
        guangbof.DXTimer2.Enabled := false;
        guangbof.Image1.Canvas.Brush.Color := clBLack;
        guangbof.Image1.Canvas.FillRect(rect(0, 0, screen.width, screen.height));
        guangbof.Label1.Visible := true;
        guangbo_state := '';
       //解锁系统
        showcursor(true);
         //解开鼠标
        rtScreen := Rect(0, 0, Screen.Width, Screen.Height);
        ClipCursor(@rtScreen);

        SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @temp, 0);
        if xieyi = 1 then
        begin
          IPX1.Close; //关闭通讯
          ipx2.close;
        end
        else
        begin
          wsocket.close;
          wsocketsize.close;
          Wsockethook.Close;
        end;
        Guangboing := false;
        GuangBof.Hide; //关闭窗口
        bmpstream.Free;
        drawstream.Free;
        if havesendvoice then //如果有传输语音
        begin
          RVOicesocket.Close; //关闭通讯
          SoundOut1.Close; //关闭语音
          voice_wsh.Clear;
          voice_wsh.Free;
        end;
      end;

      if w_yingyuan = 'mediaplaying' then //在影院
      begin
        w_yingyuan := '退出影院';
       //解锁系统
        showcursor(true);
         //解开鼠标
        rtScreen := Rect(0, 0, Screen.Width, Screen.Height);
        ClipCursor(@rtScreen);
       //开放任务条
        strpcopy(@wndClass[0], 'Shell_TrayWnd');
        WndHandle := FindWindow(@WndClass[0], nil);
        ShowWindow(wndHandle, sw_restore);
       //开放系统键
        SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @temp, 0);
      end;
      
      exit;
    end;

    if s_command = '退出教室' then
    begin
      confirmclose := true;
      close;
    end;

    if copy(s_command, 1, 8) = '锁定学生' then //命令4
    begin
      timer2.Enabled := false;
      showcursor(false);
          //屏蔽鼠标
      rtScreen := Rect(Screen.Width - 1, 0, Screen.Width, 1);
      ClipCursor(@rtScreen);

      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);
      BianColock1.Labletext := copy(s_command, 9, length(s_command) - 8);
      BiancoLock1.EXECUTE;
      BianColock1.Labletext := '';
     //   _LockKeyboard@12;
      exit;
    end;

    if copy(s_command, 1, 8) = '定时锁定' then //命令4
    begin
      timer2.Interval := strtoint(copy(s_command, 9, 5)) * 60 * 1000;
      d_memo := copy(s_command, 14, length(s_command) - 13);
      ding_stat := '定时锁定';
      timer2.Enabled := true;
      exit;
    end;

    if copy(s_command, 1, 8) = '全体黑屏' then // 全体黑屏
    begin
          //屏蔽鼠标
      rtScreen := Rect(screen.Width - 1, 0, screen.Width, 1);
      ClipCursor(@rtScreen);
         //先锁定系统
      showcursor(false);
        //关闭任务条
      strpcopy(@wndClass[0], 'Shell_TrayWnd');
      WndHandle := FindWindow(@WndClass[0], nil);
      ShowWindow(wndHandle, sw_hide);
      //屏蔽系统键
      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);      rtScreen := Rect(Screen.Width - 1, 0, Screen.Width, 1);
      heipingf.Left := 0;
      heipingf.Top := 0;
      heipingf.Width := screen.Width;
      heipingf.Height := screen.height;
      heipingf.show;
      exit;
    end;

    if copy(s_command, 1, 8) = '取消黑屏' then // 取消黑屏
    begin
         //解锁系统
      showcursor(true);
         //解开鼠标
      rtScreen := Rect(0, 0, Screen.Width, Screen.Height);
      ClipCursor(@rtScreen);
       //解开系统键
      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @temp, 0);
      //解开桌面
      //开放任务条
      strpcopy(@wndClass[0], 'Shell_TrayWnd');
      WndHandle := FindWindow(@WndClass[0], nil);
      ShowWindow(wndHandle, sw_restore);
      heipingf.close;
      LMDTrayIcon1.Active := true;
      exit;
    end;

    if copy(s_command, 1, 8) = '举手取消' then   //取消举手
    begin
      SetForeGroundWindow(form1.handle);
      Jushouf := TJushouf.Create(self);
      jushouf.Label1.Caption :='举手被取消';
      jushouf.Show;
    end;

    if copy(s_command, 1, 8) = '定时重启' then //命令4
    begin
      timer2.Interval := strtoint(copy(s_command, 9, 5)) * 60 * 1000;
      ding_stat := '定时重启';
      timer2.Enabled := true;
      exit;
    end;

    if copy(s_command, 1, 8) = '定时关机' then //命令4
    begin
      timer2.Interval := strtoint(copy(s_command, 9, 5)) * 60 * 1000;
      ding_stat := '定时关机';
      timer2.Enabled := true;
      exit;
    end;

    if copy(s_command, 1, 8) = '解除定时' then //命令4
    begin
      timer2.Enabled := false;
      exit;
    end;

    if s_command = '解锁学生' then //命令5
    begin
      timer2.Enabled := false;
      showcursor(true);
         //解开鼠标
      rtScreen := Rect(0, 0, Screen.Width, Screen.Height);
      ClipCursor(@rtScreen);

      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @temp, 0);
      BiancoLock1.Text := 'wshlock';
      BiancoLock1.UNEXECUTE;
      BiancoLock1.Text := '';
      LMDTrayIcon1.Active := true;
      exit;
    end;

    if s_command = '查看进程' then //命令6
    begin
      hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
      while hCurrentWindow <> 0 do
      begin
        if GetWindowText(hCurrentWindow, @szText, 255) > 0 then
          if (strpas(@szText) <> 'Default IME') and (copy(strpas(@szText), 1, 3) <> 'OLE') and (copy(strpas(@szText), 1, 2) <> 'DD') then
            s_jincheng := s_jincheng + strpas(@szText) + #13 + #10;
        hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
      end;
      Clisocket.SendStr('/*csh*/:' + #13 + #10 + '查看进程' + s_jincheng);
      exit;
    end;

    if copy(s_command, 1, 8) = '文件传输' then //命令7
    begin
   //写INI文件,确定教师机的IP地址
      teacher_ip := copy(s_command, 9, length(s_command) - 8);
      s_path := ExtractFilePath(Application.EXEName) + 'ftp\aftpclt.ini';
      IniFile := TIniFile.Create(s_path);
      IniFile.WriteString('TEACHER', 'IP', teacher_ip);
      IniFile.free;
         //执行文件传输服务程序
      s_path := ExtractFilePath(Application.EXEName) + 'ftp\ftpclt.exe';
      strpcopy(w_path, s_path);
      ShellExecute(handle, 'open', w_path, nil, nil, SW_ShowNormal);
      exit;
    end;

    if copy(s_command, 1, 8) = '关闭进程' then //命令8
    begin
      strpcopy(close_jingcheng, copy(s_command, 9, length(s_command) - 8));
          // find the exist calculator window
      close_hwnd := FindWindow(nil, close_jingcheng); // close the exist Calculator
      if close_HWnd <> 0 then
        SendMessage(close_HWnd, WM_CLOSE, 0, 0);
      exit;
    end;

    if copy(s_command, 1, 6) = '关闭类' then //命令9
    begin
      strpcopy(close_lei, copy(s_command, 7, length(s_command) - 6));
          // find the exist calculator window
      close_hwnd := FindWindow(close_lei, nil); // close the exist Calculator
      if close_HWnd <> 0 then
        SendMessage(close_HWnd, WM_CLOSE, 0, 0);
      exit;
    end;

    if s_command= '遥控注销' then //命令11
    begin
    Wsockethook.Close;
    showmessage('遥控辅导结束!');
    exit;
    end;

    if copy(s_command, 1, 8) = '远程命令' then //命令11
    begin
         //执行远程命令
      s_path := copy(s_command, 9, length(s_command) - 8);
      strpcopy(w_path, s_path);
      ShellExecute(handle, 'open', w_path, nil, nil, SW_ShowNormal);
      exit;
    end;
    if copy(s_command, 1, 8) = '课件广播' then //命令11
    begin
         //执行远程命令
      showcursor(false);
      s_path := copy(s_command, 9, length(s_command) - 8);
      strpcopy(w_path, s_path);
      ShellExecute(handle, 'open', w_path, nil, nil, SW_ShowNormal);
      exit;
    end;

    if copy(s_command, 1, 8) = '网上影院' then //命令12
    begin

      w_yingyuan := 'mediaplaying';
           //屏蔽鼠标
      rtScreen := Rect(screen.Width - 1, 0, screen.Width, 1);
      ClipCursor(@rtScreen);
         //先锁定系统
      showcursor(false);
        //关闭任务条
      strpcopy(@wndClass[0], 'Shell_TrayWnd');
      WndHandle := FindWindow(@WndClass[0], nil);
      ShowWindow(wndHandle, sw_hide);
      //屏蔽系统键
      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);
    //播放影院
      Gmovief := TGmovief.Create(self);
      Gmovief.MediaPlay1.Visible := false;
      Gmovief.Label1.Visible := true;
      Gmovief.Top := 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -