diff --git a/YANG Chat/YANG Chat.cpp b/YANG Chat/YANG Chat.cpp deleted file mode 100644 index 816c412..0000000 --- a/YANG Chat/YANG Chat.cpp +++ /dev/null @@ -1,108 +0,0 @@ - -// YANG Chat.cpp: 定义应用程序的类行为。 -// - -#include "pch.h" -#include "framework.h" -#include "YANG Chat.h" -#include "YANG ChatDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -// CYANGChatApp - -BEGIN_MESSAGE_MAP(CYANGChatApp, CWinApp) - ON_COMMAND(ID_HELP, &CWinApp::OnHelp) -END_MESSAGE_MAP() - - -// CYANGChatApp 构造 - -CYANGChatApp::CYANGChatApp() -{ - // 支持重新启动管理器 - m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; - - // TODO: 在此处添加构造代码, - // 将所有重要的初始化放置在 InitInstance 中 -} - - -// 唯一的 CYANGChatApp 对象 - -CYANGChatApp theApp; - - -// CYANGChatApp 初始化 - -BOOL CYANGChatApp::InitInstance() -{ - AfxInitRichEdit2(); - // 如果一个运行在 Windows XP 上的应用程序清单指定要 - // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, - //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 - INITCOMMONCONTROLSEX InitCtrls; - InitCtrls.dwSize = sizeof(InitCtrls); - // 将它设置为包括所有要在应用程序中使用的 - // 公共控件类。 - InitCtrls.dwICC = ICC_WIN95_CLASSES; - InitCommonControlsEx(&InitCtrls); - - CWinApp::InitInstance(); - - - AfxEnableControlContainer(); - - // 创建 shell 管理器,以防对话框包含 - // 任何 shell 树视图控件或 shell 列表视图控件。 - CShellManager *pShellManager = new CShellManager; - - // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题 - CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); - - // 标准初始化 - // 如果未使用这些功能并希望减小 - // 最终可执行文件的大小,则应移除下列 - // 不需要的特定初始化例程 - // 更改用于存储设置的注册表项 - // TODO: 应适当修改该字符串, - // 例如修改为公司或组织名 - SetRegistryKey(_T("应用程序向导生成的本地应用程序")); - - CYANGChatDlg dlg; - m_pMainWnd = &dlg; - INT_PTR nResponse = dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: 在此放置处理何时用 - // “确定”来关闭对话框的代码 - } - else if (nResponse == IDCANCEL) - { - // TODO: 在此放置处理何时用 - // “取消”来关闭对话框的代码 - } - else if (nResponse == -1) - { - TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); - TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n"); - } - - // 删除上面创建的 shell 管理器。 - if (pShellManager != nullptr) - { - delete pShellManager; - } - -#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS) - ControlBarCleanUp(); -#endif - - // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, - // 而不是启动应用程序的消息泵。 - return FALSE; -} - diff --git a/YANG Chat/YANG Chat.h b/YANG Chat/YANG Chat.h deleted file mode 100644 index 5508114..0000000 --- a/YANG Chat/YANG Chat.h +++ /dev/null @@ -1,32 +0,0 @@ - -// YANG Chat.h: PROJECT_NAME 应用程序的主头文件 -// - -#pragma once - -#ifndef __AFXWIN_H__ - #error "在包含此文件之前包含 'pch.h' 以生成 PCH" -#endif - -#include "resource.h" // 主符号 - - -// CYANGChatApp: -// 有关此类的实现,请参阅 YANG Chat.cpp -// - -class CYANGChatApp : public CWinApp -{ -public: - CYANGChatApp(); - -// 重写 -public: - virtual BOOL InitInstance(); - -// 实现 - - DECLARE_MESSAGE_MAP() -}; - -extern CYANGChatApp theApp; diff --git a/YANG Chat/YANG Chat.vcxproj b/YANG Chat/YANG Chat.vcxproj deleted file mode 100644 index 2e6eef8..0000000 --- a/YANG Chat/YANG Chat.vcxproj +++ /dev/null @@ -1,220 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - {105FD556-55C2-460A-B7CA-F0E2F437A770} - MFCProj - YANGChat - 10.0 - - - - Application - true - v143 - Unicode - Dynamic - - - Application - false - v143 - true - Unicode - Dynamic - - - Application - true - v143 - Unicode - Dynamic - - - Application - false - v143 - true - Unicode - Dynamic - - - - - - - - - - - - - - - - - - - - - true - - - true - - - false - - - false - C:\Users\qw200\Documents\json\include;$(IncludePath) - C:\Users\qw200\Documents\json\lib;$(LibraryPath) - - - - Use - Level3 - true - _WINDOWS;_DEBUG;%(PreprocessorDefinitions) - pch.h - - - Windows - - - false - true - _DEBUG;%(PreprocessorDefinitions) - - - 0x0804 - _DEBUG;%(PreprocessorDefinitions) - $(IntDir);%(AdditionalIncludeDirectories) - - - - - Use - Level3 - true - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) - pch.h - - - Windows - - - false - true - _DEBUG;%(PreprocessorDefinitions) - - - 0x0804 - _DEBUG;%(PreprocessorDefinitions) - $(IntDir);%(AdditionalIncludeDirectories) - - - - - Use - Level3 - true - true - true - WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) - pch.h - - - Windows - true - true - - - false - true - NDEBUG;%(PreprocessorDefinitions) - - - 0x0804 - NDEBUG;%(PreprocessorDefinitions) - $(IntDir);%(AdditionalIncludeDirectories) - - - - - Use - Level3 - true - true - true - _WINDOWS;NDEBUG;%(PreprocessorDefinitions) - pch.h - - - Windows - true - true - jsoncpp.lib - - - false - true - NDEBUG;%(PreprocessorDefinitions) - - - 0x0804 - NDEBUG;%(PreprocessorDefinitions) - $(IntDir);%(AdditionalIncludeDirectories) - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/YANG Chat/YANG Chat.vcxproj.filters b/YANG Chat/YANG Chat.vcxproj.filters deleted file mode 100644 index be61e24..0000000 --- a/YANG Chat/YANG Chat.vcxproj.filters +++ /dev/null @@ -1,69 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - - - 资源文件 - - - - - 资源文件 - - - - - 资源文件 - - - \ No newline at end of file diff --git a/YANG Chat/YANG ChatDlg.cpp b/YANG Chat/YANG ChatDlg.cpp deleted file mode 100644 index a6bd239..0000000 --- a/YANG Chat/YANG ChatDlg.cpp +++ /dev/null @@ -1,314 +0,0 @@ - -// YANG ChatDlg.cpp: 实现文件 -// - -#include "pch.h" -#include "framework.h" -#include "YANG Chat.h" -#include "YANG ChatDlg.h" -#include "afxdialogex.h" -#include "yangchatmain.h" -#include "afxdialogex.h" -#include -#include - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif -CString edition = _T("V1.0.0"); - -// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 -// pass1 消息处理程序 -#include -CString CYANGChatDlg::UTF8ToUnicode2(char* UTF8) -{ - - DWORD dwUnicodeLen; //转换后Unicode的长度 - TCHAR* pwText; //保存Unicode的指针 - CString strUnicode; //返回值 - //获得转换后的长度,并分配内存 - dwUnicodeLen = MultiByteToWideChar(CP_UTF8, 0, UTF8, -1, NULL, 0); - pwText = new TCHAR[dwUnicodeLen]; - if (!pwText) - { - return strUnicode; - } - //转为Unicode - MultiByteToWideChar(CP_UTF8, 0, UTF8, -1, pwText, dwUnicodeLen); - //转为CString - strUnicode.Format(_T("%s"), pwText); - //清除内存 - delete[]pwText; - //返回转换好的Unicode字串 - return strUnicode; -} - - -class CAboutDlg : public CDialogEx -{ -public: - CAboutDlg(); - -// 对话框数据 -#ifdef AFX_DESIGN_TIME - enum { IDD = IDD_ABOUTBOX }; -#endif - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 - -// 实现 -protected: - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialogEx::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) -END_MESSAGE_MAP() - - -// CYANGChatDlg 对话框 - - - -CYANGChatDlg::CYANGChatDlg(CWnd* pParent /*=nullptr*/) - : CDialogEx(IDD_YANG_CHAT_DIALOG, pParent) -{ - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -void CYANGChatDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialogEx::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CYANGChatDlg, CDialogEx) - ON_WM_SYSCOMMAND() - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - ON_BN_CLICKED(IDC_BUTTON1, &CYANGChatDlg::OnBnClickedButton1) -END_MESSAGE_MAP() - - -// CYANGChatDlg 消息处理程序 - -BOOL CYANGChatDlg::OnInitDialog() -{ - CDialogEx::OnInitDialog(); - - // 将“关于...”菜单项添加到系统菜单中。 - - // IDM_ABOUTBOX 必须在系统命令范围内。 - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != nullptr) - { - BOOL bNameValid; - CString strAboutMenu; - bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); - ASSERT(bNameValid); - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动 - // 执行此操作 - SetIcon(m_hIcon, TRUE); // 设置大图标 - SetIcon(m_hIcon, FALSE); // 设置小图标 - - // TODO: 在此添加额外的初始化代码 - - return TRUE; // 除非将焦点设置到控件,否则返回 TRUE -} - -void CYANGChatDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } - else - { - CDialogEx::OnSysCommand(nID, lParam); - } -} - -// 如果向对话框添加最小化按钮,则需要下面的代码 -// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序, -// 这将由框架自动完成。 - -void CYANGChatDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // 用于绘制的设备上下文 - - SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); - - // 使图标在工作区矩形中居中 - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // 绘制图标 - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialogEx::OnPaint(); - } - - CInternetSession session(_T("HttpClient")); - TCHAR* url = _T("https://api.vvhan.com/api/qqsc?key=8f2807e6a7ebfbc168f4a1ecad286283"); - CHttpFile* pfile = (CHttpFile*)session.OpenURL(url); - DWORD dwStatusCode; - pfile->QueryInfoStatusCode(dwStatusCode); - if (dwStatusCode == HTTP_STATUS_OK) - { - CString content; - CString data; - while (pfile->ReadString(data)) - { - content += data; - } - char* pch; - pch = new char[content.GetLength() * sizeof(TCHAR) + 1]; - memcpy(pch, content, content.GetLength() * sizeof(TCHAR)); - content = UTF8ToUnicode2(pch);//转换编码,不然就乱码了 - //AfxMessageBox(content); - //CString content2; - // content2 = content.Left(content.Find('r')); - // content2 = content2.Right(content.GetLength() - 1 - content.ReverseFind(':')); - //CString contenta; - // contenta = content.Left(content.Find('a')); - //contenta = content.Right(content.GetLength() - 1 - content.ReverseFind(':')); - - CString str = content; - Json::Reader reader; - Json::Value root; - CString temp; - CString temp2; - CString temp3; - CString temp4; - CString temp5; - CString temp6; - USES_CONVERSION; - char* cJson = T2A(str.GetBuffer(0)); - str.ReleaseBuffer(); - if (reader.parse(cJson, root)) { - temp = root["text"].asCString(); - //temp2 = root["data"][0]["desc"].asCString(); - if (edition == temp) { - //MessageBox(temp); - } - else { - CString tp = _T("已发布新版本\""); - CString tp2 = _T("\",为确保稳定性,请尽快更新!"); - CString tp3 = tp + temp + tp2; - MessageBox(tp3); - } - //MessageBox(temp); - - } - - } - pfile->Close(); - delete pfile; - session.Close(); -} - -//当用户拖动最小化窗口时系统调用此函数取得光标 -//显示。 -HCURSOR CYANGChatDlg::OnQueryDragIcon() -{ - return static_cast(m_hIcon); -} - - - - -void CYANGChatDlg::OnBnClickedButton1() -{ - // TODO: 在此添加控件通知处理程序代码 - int num2; - // TODO: 在此添加控件通知处理程序代码 - CInternetSession session(_T("HttpClient")); - TCHAR* url = _T("https://api.vvhan.com/api/qqsc?key=492fa5701060de4b2f30e08cbbe2defe"); - CHttpFile* pfile = (CHttpFile*)session.OpenURL(url); - DWORD dwStatusCode; - pfile->QueryInfoStatusCode(dwStatusCode); - if (dwStatusCode == HTTP_STATUS_OK) - { - CString content; - CString data; - while (pfile->ReadString(data)) - { - content += data; - } - char* pch; - pch = new char[content.GetLength() * sizeof(TCHAR) + 1]; - memcpy(pch, content, content.GetLength() * sizeof(TCHAR)); - content = UTF8ToUnicode2(pch);//转换编码,不然就乱码了 - //AfxMessageBox(content); - //CString content2; - // content2 = content.Left(content.Find('r')); - // content2 = content2.Right(content.GetLength() - 1 - content.ReverseFind(':')); - //CString contenta; - // contenta = content.Left(content.Find('a')); - //contenta = content.Right(content.GetLength() - 1 - content.ReverseFind(':')); - - CString str = content; - Json::Reader reader; - Json::Value root; - CString temp; - CString temp2; - CString temp3; - CString temp4; - CString temp5; - CString temp6; - USES_CONVERSION; - char* cJson = T2A(str.GetBuffer(0)); - str.ReleaseBuffer(); - if (reader.parse(cJson, root)) { - temp = root["text"].asCString(); - //temp2 = root["data"][0]["desc"].asCString(); - // MessageBox(temp); - num2 = _ttoi(temp); - } - - } - pfile->Close(); - delete pfile; - session.Close(); - - CString passw1; - GetDlgItem(IDC_EDIT1)->GetWindowText(passw1); - int num = _ttoi(passw1); - if (num == num2) { - //this->ShowWindow(SW_HIDE); - yangchatmain dlg; - dlg.DoModal(); - } - else { - MessageBox(_T("密码错误,请重新输入或寻求开发者帮助。")); - } - - -} diff --git a/YANG Chat/YANG ChatDlg.h b/YANG Chat/YANG ChatDlg.h deleted file mode 100644 index ecbebfb..0000000 --- a/YANG Chat/YANG ChatDlg.h +++ /dev/null @@ -1,37 +0,0 @@ - -// YANG ChatDlg.h: 头文件 -// - -#pragma once - - -// CYANGChatDlg 对话框 -class CYANGChatDlg : public CDialogEx -{ -// 构造 -public: - CYANGChatDlg(CWnd* pParent = nullptr); // 标准构造函数 - -// 对话框数据 -#ifdef AFX_DESIGN_TIME - enum { IDD = IDD_YANG_CHAT_DIALOG }; -#endif - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 - - -// 实现 -protected: - HICON m_hIcon; - - // 生成的消息映射函数 - virtual BOOL OnInitDialog(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - CString UTF8ToUnicode2(char* UTF8); - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnBnClickedButton1(); -}; diff --git a/YANG Chat/YANGChat.rc b/YANG Chat/YANGChat.rc deleted file mode 100644 index 5ca2031..0000000 Binary files a/YANG Chat/YANGChat.rc and /dev/null differ diff --git a/YANG Chat/framework.h b/YANG Chat/framework.h deleted file mode 100644 index 5672fb5..0000000 --- a/YANG Chat/framework.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 -#endif - -#include "targetver.h" - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 - -// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息 -#define _AFX_ALL_WARNINGS - -#include // MFC 核心组件和标准组件 -#include // MFC 扩展 - - -#include // MFC 自动化类 - - - -#ifndef _AFX_NO_OLE_SUPPORT -#include // MFC 对 Internet Explorer 4 公共控件的支持 -#endif -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC 对 Windows 公共控件的支持 -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include // MFC 支持功能区和控制条 - - - - - - - - - -#ifdef _UNICODE -#if defined _M_IX86 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") -#elif defined _M_X64 -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") -#else -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#endif -#endif - - diff --git a/YANG Chat/pch.cpp b/YANG Chat/pch.cpp deleted file mode 100644 index b6fb8f4..0000000 --- a/YANG Chat/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: 与预编译标头对应的源文件 - -#include "pch.h" - -// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git a/YANG Chat/pch.h b/YANG Chat/pch.h deleted file mode 100644 index 9660927..0000000 --- a/YANG Chat/pch.h +++ /dev/null @@ -1,13 +0,0 @@ -// pch.h: 这是预编译标头文件。 -// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 -// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 -// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 -// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 - -#ifndef PCH_H -#define PCH_H - -// 添加要在此处预编译的标头 -#include "framework.h" - -#endif //PCH_H diff --git a/YANG Chat/res/YANG Chat.ico b/YANG Chat/res/YANG Chat.ico deleted file mode 100644 index d56fbcd..0000000 Binary files a/YANG Chat/res/YANG Chat.ico and /dev/null differ diff --git a/YANG Chat/res/YANGChat.rc2 b/YANG Chat/res/YANGChat.rc2 deleted file mode 100644 index a7e2043..0000000 Binary files a/YANG Chat/res/YANGChat.rc2 and /dev/null differ diff --git a/YANG Chat/resource.h b/YANG Chat/resource.h deleted file mode 100644 index 230a009..0000000 --- a/YANG Chat/resource.h +++ /dev/null @@ -1,26 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ 生成的包含文件。 -// 供 YANGChat.rc 使用 -// -#define IDM_ABOUTBOX 0x0010 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_YANG_CHAT_DIALOG 102 -#define IDR_MAINFRAME 128 -#define IDD_DIALOG1 129 -#define IDC_BUTTON1 1000 -#define IDC_RICHEDIT21 1001 -#define IDC_EDIT1 1002 -#define IDC_BUTTON2 1003 -#define IDC_BUTTON3 1006 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 132 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1007 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/YANG Chat/targetver.h b/YANG Chat/targetver.h deleted file mode 100644 index 79934a3..0000000 --- a/YANG Chat/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 - -//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并 -// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 - -#include diff --git a/YANG Chat/yangchatmain.cpp b/YANG Chat/yangchatmain.cpp deleted file mode 100644 index c2161f8..0000000 --- a/YANG Chat/yangchatmain.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// yangchatmain.cpp: 实现文件 -// - -#include "pch.h" -#include "YANG Chat.h" -#include "afxdialogex.h" -#include "yangchatmain.h" -#include -#include -#pragma warning(disable:4996) -// yangchatmain 对话框 - -IMPLEMENT_DYNAMIC(yangchatmain, CDialogEx) - -yangchatmain::yangchatmain(CWnd* pParent /*=nullptr*/) - : CDialogEx(IDD_DIALOG1, pParent) -{ - -} - -yangchatmain::~yangchatmain() -{ -} - -void yangchatmain::DoDataExchange(CDataExchange* pDX) -{ - CDialogEx::DoDataExchange(pDX); -} - - -BEGIN_MESSAGE_MAP(yangchatmain, CDialogEx) - ON_BN_CLICKED(IDC_BUTTON1, &yangchatmain::OnBnClickedButton1) - -END_MESSAGE_MAP() - - -// yangchatmain 消息处理程序 - - - -// pass1 消息处理程序 -#include -CString yangchatmain::UTF8ToUnicode25(char* UTF8) -{ - - DWORD dwUnicodeLen; //转换后Unicode的长度 - TCHAR* pwText; //保存Unicode的指针 - CString strUnicode; //返回值 - //获得转换后的长度,并分配内存 - dwUnicodeLen = MultiByteToWideChar(CP_UTF8, 0, UTF8, -1, NULL, 0); - pwText = new TCHAR[dwUnicodeLen]; - if (!pwText) - { - return strUnicode; - } - //转为Unicode - MultiByteToWideChar(CP_UTF8, 0, UTF8, -1, pwText, dwUnicodeLen); - //转为CString - strUnicode.Format(_T("%s"), pwText); - //清除内存 - delete[]pwText; - //返回转换好的Unicode字串 - return strUnicode; -} -#define _UNICODE -#include - - -void yangchatmain::OnBnClickedButton1() -{ - CString url2; - GetDlgItem(IDC_EDIT1)->GetWindowText(url2); - wchar_t* unicodeStr = url2.GetBuffer(); - int unicodeLen = url2.GetLength(); - - std::string utf8Str; - for (int i = 0; i < unicodeLen; i++) { - wchar_t ch = unicodeStr[i]; - if (ch < 0x80) { - utf8Str += static_cast(ch); - } - else if (ch < 0x800) { - utf8Str += static_cast((ch >> 6) | 0xc0); - utf8Str += static_cast((ch & 0x3f) | 0x80); - } - else { - utf8Str += static_cast((ch >> 12) | 0xe0); - utf8Str += static_cast(((ch >> 6) & 0x3f) | 0x80); - utf8Str += static_cast((ch & 0x3f) | 0x80); - } - } - - CString encodedUrl; - int utf8Len = utf8Str.length(); - for (int i = 0; i < utf8Len; i++) { - unsigned char ch = utf8Str[i]; - char hexStr[4]; - sprintf_s(hexStr, 4, "%%%02X", ch); - encodedUrl += CString(hexStr); - - } - // TODO: 在此添加控件通知处理程序代码 - int num2; - CString asd = _T("http://www.emmapi.com/chatgpt?text="); - CString asd1 = asd + encodedUrl; - // TODO: 在此添加控件通知处理程序代码 - CInternetSession session(_T("HttpClient")); - TCHAR* url = asd1.GetBuffer();;//https://v1.apigpt.cn/?q=你好&apitype=sql - CHttpFile* pfile = (CHttpFile*)session.OpenURL(url); - DWORD dwStatusCode; - pfile->QueryInfoStatusCode(dwStatusCode); - if (dwStatusCode == HTTP_STATUS_OK) - { - CString content; - CString data; - while (pfile->ReadString(data)) - { - content += data; - } - char* pch; - pch = new char[content.GetLength() * sizeof(TCHAR) + 1]; - memcpy(pch, content, content.GetLength() * sizeof(TCHAR)); - content = UTF8ToUnicode25(pch);//转换编码,不然就乱码了 - //AfxMessageBox(content); - //CString content2; - // content2 = content.Left(content.Find('r')); - // content2 = content2.Right(content.GetLength() - 1 - content.ReverseFind(':')); - //CString contenta; - // contenta = content.Left(content.Find('a')); - //contenta = content.Right(content.GetLength() - 1 - content.ReverseFind(':')); - - CString str = content; - Json::Reader reader; - Json::Value root; - CString temp; - CString temp2; - CString temp3; - CString temp4; - CString temp5; - CString temp6; - USES_CONVERSION; - char* cJson = T2A(str.GetBuffer(0)); - str.ReleaseBuffer(); - if (reader.parse(cJson, root)) { - temp = root["text"].asCString(); - CString chatgpt = _T("YANG Chat:\n") + temp; - SetDlgItemText(IDC_RICHEDIT21, chatgpt); - //temp2 = root["data"][0]["desc"].asCString(); - - - } - - } - pfile->Close(); - delete pfile; - session.Close(); - - - - -} - diff --git a/YANG Chat/yangchatmain.h b/YANG Chat/yangchatmain.h deleted file mode 100644 index dd0b4f3..0000000 --- a/YANG Chat/yangchatmain.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include "afxdialogex.h" - - -// yangchatmain 对话框 - -class yangchatmain : public CDialogEx -{ - DECLARE_DYNAMIC(yangchatmain) - -public: - yangchatmain(CWnd* pParent = nullptr); // 标准构造函数 - virtual ~yangchatmain(); - -// 对话框数据 -#ifdef AFX_DESIGN_TIME - enum { IDD = IDD_DIALOG1 }; -#endif - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 - - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnBnClickedButton1(); - CString UTF8ToUnicode25(char* UTF8); -};