添加广播MDNS服务

This commit is contained in:
2024-08-19 09:39:32 +08:00
parent 1f7bc017ca
commit 0a5b0db9a5
192 changed files with 22181 additions and 616 deletions

View File

@@ -0,0 +1,52 @@
#ifndef LICENSECONFIRMWINDOW_H
#define LICENSECONFIRMWINDOW_H
#include <QDialog>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>
class LicenseConfirmWindow : public QDialog
{
Q_OBJECT
public:
explicit LicenseConfirmWindow(const QString& message, QWidget* parent = nullptr)
{
messageLabel = new QLabel(message, this);
confirmButton = new QPushButton("确认", this);
cancelButton = new QPushButton("取消", this);
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(messageLabel);
QHBoxLayout* buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(confirmButton);
buttonLayout->addWidget(cancelButton);
layout->addLayout(buttonLayout);
setLayout(layout);
setWindowTitle("获取License");
resize(260, 100); // 设置对话框的大小
connect(confirmButton, &QPushButton::clicked, this, &LicenseConfirmWindow::onConfirmClicked);
connect(cancelButton, &QPushButton::clicked, this, &LicenseConfirmWindow::onCancelClicked);
}
private slots:
void onConfirmClicked()
{
accept();
}
void onCancelClicked()
{
reject();
}
private:
QLabel* messageLabel;
QPushButton* confirmButton;
QPushButton* cancelButton;
};
#endif // LICENSECONFIRMWINDOW_H

View File

@@ -1,17 +1,11 @@
// LicenseGenerate.cpp
#include "LicenseGenerate.h"
#define PIX_HARDWARE_INFO_BYTES 32
#define PIX_LICENCE_BYTES 128
typedef const char* (*pix_license_generate_version_func)();
typedef int (*pix_license_generate_func)(const unsigned char*, int, unsigned char*, int);
void licenseGenerate()
bool licenseGenerate(const unsigned char* hardware_info, unsigned char* license_info)
{
unsigned char hardware_info[PIX_HARDWARE_INFO_BYTES] = { };
unsigned char license_info[PIX_LICENCE_BYTES] = { 0 };
// 获取当前路径
wchar_t currentPath[MAX_PATH];
GetCurrentDirectoryW(MAX_PATH, currentPath);
@@ -25,8 +19,7 @@ void licenseGenerate()
HINSTANCE hDLL = LoadLibraryW(dllPath.c_str());
if (hDLL == NULL) {
std::cerr << "Failed to load DLL. Error code: " << GetLastError() << std::endl;
FreeLibrary(hDLL);
return;
return false;
}
pix_license_generate_version_func pix_license_generate_version =
(pix_license_generate_version_func)GetProcAddress(hDLL, "pix_license_generate_version");
@@ -35,23 +28,25 @@ void licenseGenerate()
if (pix_license_generate_version == NULL || pix_license_generate == NULL) {
std::cerr << "Failed to find one or more functions." << std::endl;
FreeLibrary(hDLL);
return;
return false;
}
printf("pix_license_generate_version is %s\n",
pix_license_generate_version());
printf("Hardware info:");
for (int j = 0; j < PIX_HARDWARE_INFO_BYTES; ++j) {
hardware_info[j] = j;
//hardware_info[j] = j;
printf("0x%02x, ", hardware_info[j]);
}
printf("\n");
// return 限制不调用 pix_license_generate, 防止减少license个数
return;
return false;
int ret = pix_license_generate(hardware_info, PIX_HARDWARE_INFO_BYTES,
license_info, PIX_LICENCE_BYTES);
if (ret != SDK_CODE_OK) {
printf("Fail to generate license with %d\n", ret);
FreeLibrary(hDLL);
return false;
}
else {
printf("License is\n");
@@ -62,7 +57,6 @@ void licenseGenerate()
}
FreeLibrary(hDLL);
return;
return true;
}

View File

@@ -10,6 +10,9 @@
#include <stdio.h>
#include "p_code.h"
void licenseGenerate();
#define PIX_HARDWARE_INFO_BYTES 32
#define PIX_LICENCE_BYTES 128
bool licenseGenerate(const unsigned char* hardware_info, unsigned char* license_info);
#endif