• 大小: 15.77MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-14
  • 语言: 其他
  • 标签: 远程  桌面  源码  Qt  

资源简介

自己写着玩的,实现远程桌面实时监控和鼠标锁定,局域网自动发现,绿色 免安装

资源截图

代码片段和文件信息

#include “client.h“

#include 
#include 
#include 

#define SERVER_PORT 44444
#define UDP_CLIENT_PORT 44448
#define UDP_SERVER_PORT 44446

Client::Client(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);

isConnected_ = false;
isRecord_ = false;

socket_ = new QTcpSocket();
socket_->setSocketOption(QAbstractSocket::LowDelayOption 1);
connect(socket_ SIGNAL(readyRead()) this SLOT(readFortune()));
connect(socket_ SIGNAL(error(QAbstractSocket::SocketError)) this SLOT(displayerror(QAbstractSocket::SocketError)));
connect(socket_ SIGNAL(stateChanged(QAbstractSocket::SocketState)) this SLOT(stateChanged(QAbstractSocket::SocketState)));

udpSocket_ = new QUdpSocket(this);
udpSocket_->bind(UDP_CLIENT_PORTQUdpSocket::ShareAddress);
connect(udpSocket_ SIGNAL(readyRead()) this SLOT(readPendingDatagrams()));

connect(&timer_ SIGNAL(timeout()) this SLOT(serverTimeOut()));
timer_.start(5000);

ui.lineEdit_ip->setText(“192.168.“);

showMaximized();
}

Client::~Client()
{

}

void Client::connectServer(QString ip)
{
socket_->abort();
receiveData_.clear();

socket_->connectToHost(QHostAddress(ip) SERVER_PORT);

ui.lineEdit_ip->setText(ip);
}

void Client::readFortune()
{
quint64 bytesAvailable = socket_->bytesAvailable();
if (bytesAvailable <= 0)
return;

QByteArray data = socket_->read(bytesAvailable);
//qDebug() << “from:“ << socket_->peerAddress().toString() << “ size:“ << data.size();
receiveData_.append(data);

processData();
}

void Client::displayerror(QAbstractSocket::SocketError socketError)
{
switch (socketError) {
case QAbstractSocket::RemoteHostClosedError:
break;
case QAbstractSocket::HostNotFoundError:
QMessageBox::information(this tr(“Fortune Client“)
tr(“The host was not found. Please check the “
“host name and port settings.“));

break;
case QAbstractSocket::ConnectionRefusedError:
QMessageBox::information(this tr(“Fortune Client“)
tr(“The connection was refused by the peer. “
“Make sure the fortune server is running “
“and check that the host name and port “
“settings are correct.“));
break;
default:
QMessageBox::information(this tr(“Fortune Client“)
tr(“The following error occurred: %1.“)
.arg(socket_->errorString()));
}
}

void Client::stateChanged(QAbstractSocket::SocketState socketState)
{
switch (socketState) {
case QAbstractSocket::HostLookupState:
case QAbstractSocket::ConnectingState:
break;
case QAbstractSocket::ConnectedState:
isConnected_ = true;
break;
case QAbstractSocket::BoundState:
case QAbstractSocket::ListeningState:
break;
case QAbstractSocket::ClosingState:
case QAbstractSocket::UnconnectedState:
{
isConnected_ = false;
isRecord_ = false;
ui.pushButton_record->setText(QString::fromLocal8Bit(“录像“));
break;
}
default:
Q_ASSERT_X(0 “stateChanged“ “Unknown 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-10-10 09:26  Client\
     文件        7512  2017-07-20 20:33  Client\client.cpp
     文件        1296  2017-05-19 17:47  Client\client.h
     文件          66  2017-04-28 09:39  Client\client.qrc
     文件        6916  2017-05-19 17:49  Client\client.ui
     文件       10506  2017-04-28 09:39  Client\Client.vcxproj
     文件        2667  2017-04-28 09:39  Client\Client.vcxproj.filters
     文件        1228  2017-07-06 16:30  Client\Client.vcxproj.user
     文件         536  2017-05-02 13:43  Client\main.cpp
     目录           0  2017-04-28 09:39  Client\Resources\
     目录           0  2017-10-10 09:26  Monitor\
     文件        1424  2017-04-28 09:39  Monitor.sln
     文件         824  2017-05-19 17:10  Monitor\main.cpp
     文件       12009  2017-05-01 17:32  Monitor\Monitor.vcxproj
     文件        2964  2017-05-01 17:32  Monitor\Monitor.vcxproj.filters
     文件        1078  2017-07-06 16:30  Monitor\Monitor.vcxproj.user
     文件        1005  2017-05-19 11:30  Monitor\picthread.cpp
     文件         328  2017-04-28 09:19  Monitor\picthread.h
     目录           0  2017-04-27 17:13  Monitor\Resources\
     文件        4719  2017-05-19 17:32  Monitor\server.cpp
     文件         662  2017-05-19 17:35  Monitor\server.h
     文件        1856  2017-05-19 17:37  Monitor\udpserver.cpp
     文件         481  2017-05-19 17:37  Monitor\udpserver.h
     目录           0  2017-10-10 09:26  Win32\
     目录           0  2017-05-19 11:08  Win32\Release\
     文件       69632  2017-05-19 17:32  Win32\Release\Client.exe
     文件       35328  2017-05-19 17:36  Win32\Release\Monitor.exe
     文件      455328  2017-02-28 15:37  Win32\Release\msvcp120.dll
     文件      970912  2017-02-28 15:37  Win32\Release\msvcr120.dll
     目录           0  2017-05-02 13:44  Win32\Release\plugins\
     目录           0  2017-05-02 13:44  Win32\Release\plugins\audio\
............此处省略121个文件信息

评论

共有 条评论