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

📄 main.pas

📁 这是一个非常好的教师和学生沟通用的电子教室!
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        //解锁系统
      showcursor(true);
         //解开鼠标
      rtScreen := Rect(0, 0, Screen.Width, Screen.Height);
      ClipCursor(@rtScreen);
       //解开系统键
      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @temp, 0);
      //解开桌面
      hDesktop := FindWindow('Progman', nil);
      ShowWindow(hDesktop, SW_SHOW);
      //开放任务条
      strpcopy(@wndClass[0], 'Shell_TrayWnd');
      WndHandle := FindWindow(@WndClass[0], nil);
      ShowWindow(wndHandle, sw_restore);


      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
            SendMessage(hCurrentWindow, WM_CLOSE, 0, 0);
            exit;
          end;
        hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
      end;
      exit;
    end;

    if copy(s_command, 1, 8) = '呼叫会议' then
    begin
       //锁定学生
      showcursor(false);
          //屏蔽鼠标
      rtScreen := Rect(Screen.Width - 1, 0, Screen.Width, 1);
      ClipCursor(@rtScreen);
       //关闭任务条
      strpcopy(@wndClass[0], 'Shell_TrayWnd');
      WndHandle := FindWindow(@WndClass[0], nil);
      ShowWindow(wndHandle, sw_hide);
       //屏蔽系统键
      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);
        //锁定桌面
      hDesktop := FindWindow('Progman', nil);
      ShowWindow(hDesktop, SW_Hide);

      BiancoLock1.EXECUTE;
      teacher_ip := copy(s_command, 9, length(s_command) - 8); //教师机的名称
      inifilename := ExtractFilePath(Application.EXEName) + 'callwsh.cnf';
      IniFile := TIniFile.Create(IniFileName);
      IniFile.Writestring('ConferenceShortcut', 'ConfName', teacher_ip);
      IniFile.Writestring('ConferenceShortcut', 'Address', teacher_ip);
      IniFile.WriteInteger('ConferenceShortcut', 'CallFlags', 65551);
      IniFile.WriteInteger('ConferenceShortcut', 'Transport', 1);
      IniFile.Free;
      ShellExecute(handle, 'open', pchar(inifilename), nil, nil, SW_MINIMIZE);
      sleep(20000);
      deletefile(inifilename);

      //最小化
      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
            AppActivate(@szText);
            SendKeys('%c{left}n', false);
            exit;
          end;
        hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
      end;
      exit;
    end;

    if copy(s_command, 1, 8) = '桌面锁定' then
    begin
       //屏蔽鼠标
      rtScreen := Rect(1, 1, 2, 2);
      ClipCursor(@rtScreen);
       //关闭任务条
      strpcopy(@wndClass[0], 'Shell_TrayWnd');
      WndHandle := FindWindow(@WndClass[0], nil);
      ShowWindow(wndHandle, sw_hide);
       //屏蔽系统键
      SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);
        //锁定桌面
      hDesktop := FindWindow('Progman', nil);
      ShowWindow(hDesktop, SW_Hide);
      //最小话
      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
            AppActivate(@szText);
            SendKeys('%c{left}n', false);
            exit;
          end;
        hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
      end;
      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);
      //解开桌面
      hDesktop := FindWindow('Progman', nil);
      ShowWindow(hDesktop, SW_SHOW);
      //开放任务条
      strpcopy(@wndClass[0], 'Shell_TrayWnd');
      WndHandle := FindWindow(@WndClass[0], nil);
      ShowWindow(wndHandle, sw_restore);
      exit;
    end;

    if copy(s_command, 1, 8) = '全屏广播' then
    begin
      hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
      while hCurrentWindow <> 0 do
      begin
        if GetWindowText(hCurrentWindow, @szText, 255) > 0 then
          if (pos('的程序', strpas(@szText)) > 0) or (pos('的桌面机', strpas(@szText)) > 0) then
          begin
            AppActivate(@szText);
            SendKeys('%~', false);
            //SendMessage(hCurrentWindow, WM_CLOSE, 0, 0);
            exit;
          end;
        hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
      end;
      exit;
    end;

    if copy(s_command, 1, 8) = '关闭话筒' then
    begin
      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
            AppActivate(@szText);
            SendKeys('^m', false);
          //  SendMessage(hCurrentWindow, WM_CLOSE, 0, 0);
            exit;
          end;
        hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
      end;
      exit;
    end;

    if copy(s_command, 1, 7) = '640*480' then
    begin
     // showmessage('640');
      DynamicResolution(640, 480);
      exit;
    end;

    if copy(s_command, 1, 7) = '800*600' then
    begin
     //showmessage('800');
      DynamicResolution(800, 600);
      exit;
    end;

    if copy(s_command, 1, 8) = '示范教学' then
    begin
      guangbo_state := '';
      priscreen := Tbitmap.Create;
      priscreen.Width := screen.Width;
      priscreen.Height := screen.Height;
       if wsocket.State<>wsclosed then wsocket.close;
      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();

       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;
      s_guangbo := true;


      getime := strtoint(copy(s_command, 9, length(s_command) - 8));
      PingmuTimer.Interval := getime;
      getime:=1;
      sleep(500);
      PIngmuTImer.Enabled := true;
      exit;
    end;

    if copy(s_command, 1, 8) = '停止示范' then
    begin
      if s_guangbo = true then
      begin
        guangbo_state := '';
        shang_ci := 0;
        shang_size := 0;
        quan_screen := false;
        s_guangbo := false;
        PIngmuTImer.Enabled := false;
        //清空流
        priscreen.FreeImage;
        priscreen.Free;
        priscreen := nil;
        exit;
      //Clisocket.SendStr('/*csh*/:' + #13 + #10 + '停止示范');
      end;
    end;

    if copy(s_command, 1, 8) = '遥控辅导' then
    begin
      guangbo_state := '遥控辅导';
      priscreen := Tbitmap.Create;
      priscreen.Width := screen.Width;
      priscreen.Height := screen.Height;
     // Wsocket.Close;
   //  打开自己的UDP协议,发送数据
       if wsocket.State<>wsclosed then wsocket.close;
      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();

       if wsockethook.State<>wsclosed then WSocketHook.Close;
      WSockethook.Proto := 'udp';
      WSockethook.Addr := '0.0.0.0';
      WSockethook.MultiCast := true;
      WSocketHook.ReuseAddr := true;
      WSockethook.Port := '999';
      WSocketHook.MultiCastAddrStr := '225.1.2.4';
      WSockethook.Listen;

       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;

      s_guangbo := true;

      getime := strtoint(copy(s_command, 9, length(s_command) - 8));
      PingmuTimer.Interval := getime;
      getime:=1;
      sleep(500);
    //  getime := strtoint(copy(s_command, 9, length(s_command) - 8));
      PIngmuTImer.Enabled := true;
//      exit;
    end;

  end;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);


begin

//发送信息
  if Clisocket.State <> wsConnected then
  begin
    SetForegroundWindow(Form1.Handle);
    Application.MessageBox('网络未连接。举手失败!', '提示信息', MB_OK + MB_ICONEXCLAMATION);
    exit;
  end;
  Clisocket.SendStr('/*csh*/:' + #13 + #10 + '电子举手' + trim(localiplist.strings[0]));
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
var
  wndHandle: Thandle; //关闭任务条
  wndClass: array[0..50] of char;
begin
  form1.WindowState := wsMinimized;
  form1.Hide;
end;

procedure TForm1.LMDGlobalHotKey1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  BitBtn1Click(sender);
end;



procedure TForm1.BiancoLock1CloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  if BiancoLock1.Text = 'wshlock' then
    canclose := true
  else
    canclose := false;
end;

procedure TForm1.LMDGlobalHotKey2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  confirmclose := true;
  close;
end;

procedure TForm1.CliSocketSessionClosed(Sender: TObject; Error: Word);
begin
  Panel1.Caption := '正在登陆...';
 //发送登陆消息
  loginwsocket.Close;
  LoginwSocket.Multicast := true;
  loginwSocket.Proto := 'udp';
  LoginwSocket.Addr := '225.1.2.8'; // or whatever you decide
  loginwSocket.Port := '1525';
  loginwSocket.Connect;
  LoginTimer.Enabled := true;
end;

procedure TForm1.BiancoLock1Close(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TForm1.LMDGlobalHotKey3KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  banquan: string;
begin
  about.Label1.Visible:=true;
  about.Timer1.Enabled:=false;
  about.ShowModal;
  about.Label2.Caption:='教师IP地址:'+teacherip;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
{ var
  myreg: Tregistry;}
var
  nNameSize: Cardinal;
  chName: array[0..MAX_COMPUTERNAME_LENGTH] of char;
begin
  Timer1.Enabled := false;
  s_computername := '';
  nNameSize := MAX_COMPUTERNAME_LENGTH + 1;
  FillMemory(@chName, nNameSize, $00);
  GetComputerName(chName, nNameSize);
  s_computername := chName; //得到计算机名称
  BitBtn3Click(sender);
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var
  rtScreen: TRect;
  temp: integer;
begin
  timer2.Enabled := false;
  if ding_stat = '定时锁定' then
  begin
    showcursor(false);
          //屏蔽鼠标
    rtScreen := Rect(Screen.Width - 1, 0, Screen.Width, 1);
    ClipCursor(@rtScreen);

    SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);
    BianColock1.Labletext := d_memo;
    BiancoLock1.EXECUTE;
    BianColock1.Labletext := '';

    Clisocket.SendStr('/*csh*/:' + #13 + #10 + '定时锁定' + s_computername);
  end;

  if ding_stat = '定时重启' then
  begin
    Guangboing := false;
    confirmclose := true;
    Clisocket.Close;
    SrvSocket.Close;
  //  loginwsocket.Close;
   // AdjustToken;
    ExitWindowsEx(EWX_REBOOT, 0);
    confirmclose := true;
    close;
    //ShellExecute(handle, 'open', 'RUNDLL.EXE', 'user.exe,exitwindowsexec', nil, SW_ShowNormal);
    exit;
  end;

  if ding_stat = '定时关机' then
  begin
    confirmclose := true;
    Guangboing := false;
    confirmclose := true;
    Clisocket.Close;
    SrvSocket.Close;
 //   loginwsocket.Close;
  //  AdjustToken;
    ShellExecute(handle, 'open', 'RUNDLL32.EXE', 'user.exe,ExitWindows', nil, SW_ShowNormal);
    confirmclose := true;
    close;
    exit;
  end;

end;

procedure TForm1.WSocketDataAvailable(Sender: TObject; Error: Word);
var
  recbuf: array[0..1023] of char;
begin
  recbuf := #0;
  //wsocket.ReceiveFrom(

  len := Wsocket.Receive(@recbuf, 1024);
  if len > 0 then
  begin
    allsize := allsize + len;
    //读入发来的长度数据
     // if bmpstream <> nil then
    try
      bmpstream.WriteBuffer(recbuf, len);

⌨️ 快捷键说明

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