464 lines
16 KiB
C
464 lines
16 KiB
C
|
#include <windows.h>
|
|||
|
#include <stdio.h>
|
|||
|
|
|||
|
#define START_ACTION_BTN_ID 1001 // <20><><EFBFBD>弤<EFBFBD>ť ID
|
|||
|
|
|||
|
#define ENGLISH 0 // Ӣ<><D3A2>
|
|||
|
#define CHINESE 1 // <20><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define INFO_LEFT_MARGIN 40 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߾<EFBFBD>
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
WNDCLASSEX wc;
|
|||
|
HWND hwnd;
|
|||
|
MSG msg;
|
|||
|
HWND SystemLang;
|
|||
|
HWND SystemVersion;
|
|||
|
HWND ActionServerText;
|
|||
|
HWND ActionServerAddr;
|
|||
|
HWND ActionBtn;
|
|||
|
|
|||
|
|
|||
|
// <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|||
|
int CurSystemLang = 0;
|
|||
|
|
|||
|
// <20><>ǰϵͳ<CFB5>汾ѡ<E6B1BE><D1A1>
|
|||
|
int CurSystemVersion = 0;
|
|||
|
|
|||
|
// <20><><EFBFBD>ż<EFBFBD><C5BC><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ͷ<EFBFBD>Ӧ<EFBFBD><D3A6>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ľṹ<C4BD><E1B9B9>
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
char *Key;
|
|||
|
char *English;
|
|||
|
char *Chinese;
|
|||
|
}SYSTEM_VERSION,*SYSTEM_VERSION_PTR;
|
|||
|
|
|||
|
//<2F><><EFBFBD>ż<EFBFBD><C5BC><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ľṹ<C4BD><E1B9B9>
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
char *Key;
|
|||
|
char *ActionServer;
|
|||
|
}ACTION_INFO,*ACTION_INFO_PTR;
|
|||
|
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
const char *SystemLangList[] = {
|
|||
|
"English",
|
|||
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|||
|
NULL,
|
|||
|
};
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|||
|
const char *ActionServerStr[] = {
|
|||
|
"Action Server : ",
|
|||
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : ",
|
|||
|
};
|
|||
|
|
|||
|
// <20><><EFBFBD>ť<EEB0B4>ı<EFBFBD>
|
|||
|
const char *ActionBtnStr[] = {
|
|||
|
"Start Action",
|
|||
|
"<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|||
|
};
|
|||
|
|
|||
|
ACTION_INFO ActionInfo;
|
|||
|
|
|||
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>汾<EFBFBD><E6B1BE>Ϣ
|
|||
|
const SYSTEM_VERSION SystemVersionList[] = {
|
|||
|
{.Key = "FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4", .English = "Windows 7 Pro", .Chinese = "Windows 7 רҵ<D7A8><D2B5>"},
|
|||
|
{.Key = "MRPKT-YTG23-K7D7T-X2JMM-QY7MG", .English = "Windows 7 Pro N", .Chinese = "Windows 7 רҵ<D7A8><D2B5> N"},
|
|||
|
{.Key = "W82YF-2Q76Y-63HXB-FGJG9-GF7QX", .English = "Windows 7 Pro E", .Chinese = "Windows 7 רҵ<D7A8><D2B5> E"},
|
|||
|
{.Key = "33PXH-7Y6KF-2VJC9-XBBR8-HVTHH", .English = "Windows 7 Enterprise", .Chinese = "Windows 7 <20><>ҵ<EFBFBD><D2B5>"},
|
|||
|
{.Key = "YDRBP-3D83W-TY26F-D46B2-XCKRJ", .English = "Windows 7 Enterprise N", .Chinese = "Windows 7 <20><>ҵ<EFBFBD><D2B5> N"},
|
|||
|
{.Key = "C29WB-22CC8-VJ326-GHFJW-H9DH4", .English = "Windows 7 Enterprise E", .Chinese = "Windows 7 <20><>ҵ<EFBFBD><D2B5> E"},
|
|||
|
{.Key = "NG4HW-VH26C-733KW-K6F98-J8CK4", .English = "Windows 8 Pro", .Chinese = "Windows 8 רҵ<D7A8><D2B5>"},
|
|||
|
{.Key = "XCVCF-2NXM9-723PB-MHCB7-2RYQQ", .English = "Windows 8 Pro N", .Chinese = "Windows 8 רҵ<D7A8><D2B5> N"},
|
|||
|
{.Key = "32JNW-9KQ84-P47T8-D8GGY-CWCK7", .English = "Windows 8 Enterprise", .Chinese = "Windows 8 <20><>ҵ<EFBFBD><D2B5>"},
|
|||
|
{.Key = "JMNMF-RHW7P-DMY6X-RF3DR-X2BQT", .English = "Windows 8 Enterprise N", .Chinese = "Windows 8 <20><>ҵ<EFBFBD><D2B5> N"},
|
|||
|
{.Key = "GCRJD-8NW9H-F2CDX-CCM8D-9D6T9", .English = "Windows 8.1 Pro", .Chinese = "Windows 8.1 רҵ<D7A8><D2B5>"},
|
|||
|
{.Key = "HMCNV-VVBFX-7HMBH-CTY9B-B4FXY", .English = "Windows 8.1 Pro N", .Chinese = "Windows 8.1 רҵ<D7A8><D2B5> N"},
|
|||
|
{.Key = "MHF9N-XY6XB-WVXMC-BTDCT-MKKG7", .English = "Windows 8.1 Enterprise", .Chinese = "Windows 8.1 <20><>ҵ<EFBFBD><D2B5>"},
|
|||
|
{.Key = "TT4HM-HN7YT-62K67-RGRQJ-JFFXW", .English = "Windows 8.1 Enterprise N", .Chinese = "Windows 8.1 <20><>ҵ<EFBFBD><D2B5> N"},
|
|||
|
{.Key = "TX9XD-98N7V-6WMQ6-BX7FG-H8Q99", .English = "Windows 10/11 Home", .Chinese = "Windows 10/11 <20><>ͥ<EFBFBD><CDA5>"},
|
|||
|
{.Key = "PVMJN-6DFY6-9CCP6-7BKTT-D3WVR", .English = "Windows 10/11 Home zh-cn", .Chinese = "Windows 10/11 <20><>ͥ<EFBFBD><CDA5><EFBFBD>İ<EFBFBD>"},
|
|||
|
{.Key = "W269N-WFGWX-YVC9B-4J6C9-T83GX", .English = "Windows 10/11 Pro", .Chinese = "Windows 10/11 רҵ<D7A8><D2B5>"},
|
|||
|
{.Key = "MH37W-N47XK-V7XM9-C7227-GCQG9", .English = "Windows 10/11 Pro N", .Chinese = "Windows 10/11 רҵ<D7A8><D2B5> N"},
|
|||
|
{.Key = "NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J", .English = "Windows 10/11 Pro Workstation", .Chinese = "Windows 10/11 רҵ<D7A8><D2B5><EFBFBD><EFBFBD>վ<EFBFBD><D5BE>"},
|
|||
|
{.Key = "9FNHH-K3HBT-3W4TD-6383H-6XYWF", .English = "Windows 10/11 Pro Workstation N", .Chinese = "Windows 10/11 רҵ<D7A8><D2B5><EFBFBD><EFBFBD>վ<EFBFBD><D5BE> N"},
|
|||
|
{.Key = "6TP4R-GNPTD-KYYHQ-7B7DP-J447Y", .English = "Windows 10/11 Pro Edu", .Chinese = "Windows 10/11 רҵ<D7A8><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|||
|
{.Key = "YVWGF-BXNMC-HTQYQ-CPQ99-66QFC", .English = "Windows 10/11 Pro Edu N", .Chinese = "Windows 10/11 רҵ<D7A8><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> N"},
|
|||
|
{.Key = "NW6C2-QMPVW-D7KKK-3GKT6-VCFB2", .English = "Windows 10/11 Edu", .Chinese = "Windows 10/11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|||
|
{.Key = "2WH4N-8QGBV-H22JP-CT43Q-MDWWJ", .English = "Windows 10/11 Edu N", .Chinese = "Windows 10/11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> N"},
|
|||
|
{.Key = "NPPR9-FWDCX-D2C8J-H872K-2YT43", .English = "Windows 10/11 Enterprise", .Chinese = "Windows 10/11 <20><>ҵ<EFBFBD><D2B5>"},
|
|||
|
{.Key = "DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4", .English = "Windows 10/11 Enterprise N", .Chinese = "Windows 10/11 <20><>ҵ<EFBFBD><D2B5> N"},
|
|||
|
{.Key = "YYVX9-NTFWV-6MDM3-9PT4T-4M68B", .English = "Windows 10/11 Enterprise G", .Chinese = "Windows 10/11 <20><>ҵ<EFBFBD><D2B5> G"},
|
|||
|
{.Key = "44RPN-FTY23-9VTTB-MP9BX-T84FV", .English = "Windows 10/11 Enterprise G N", .Chinese = "Windows 10/11 <20><>ҵ<EFBFBD><D2B5> G N"},
|
|||
|
{.Key = "M7XTQ-FN8P6-TTKYV-9D4CC-J462D", .English = "Windows 10/11 LTSC", .Chinese = "Windows 10/11 <20><><EFBFBD><EFBFBD>֧<EFBFBD>ְ<EFBFBD>"},
|
|||
|
{.Key = "92NFX-8DJQP-P6BBQ-THF9C-7CG2H", .English = "Windows 10/11 LTSC N", .Chinese = "Windows 10/11 <20><><EFBFBD><EFBFBD>֧<EFBFBD>ְ<EFBFBD> N"},
|
|||
|
{.Key = "KBN8V-HFGQ4-MGXVD-347P6-PDQGT", .English = "Windows 10/11 IoT LTSC", .Chinese = "Windows 10/11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>֧<EFBFBD>ְ<EFBFBD>"},
|
|||
|
{.Key = "DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ", .English = "Windows 10/11 LTSB 2016", .Chinese = "Windows 10/11 <20><><EFBFBD><EFBFBD>֧<EFBFBD>ְ<EFBFBD> 2016"},
|
|||
|
{.Key = "QFFDN-GRT3P-VKWWX-X7T3R-8B639", .English = "Windows 10/11 LTSB 2016 N", .Chinese = "Windows 10/11 <20><><EFBFBD><EFBFBD>֧<EFBFBD>ְ<EFBFBD> 2016 N"},
|
|||
|
{.Key = "VDYBN-27WPP-V4HQT-9VMD4-VMK7H", .English = "Windows Server 2022 Standard", .Chinese = "Windows Server 2022 <20><><EFBFBD><D7BC>"},
|
|||
|
{.Key = "WX4NM-KYWYW-QJJR4-XV3QB-6VM33", .English = "Windows Server 2022 Datacenter", .Chinese = "Windows Server 2022 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>"},
|
|||
|
{.Key = "NTBV8-9K7Q8-V27C6-M2BTV-KHMXV", .English = "Windows Server 2022 Datacenter Azure", .Chinese = "Windows Server 2022 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> Azure"},
|
|||
|
{.Key = "N69G4-B89J2-4G8F4-WWYCC-J464C", .English = "Windows Server 2019 Standard", .Chinese = "Windows Server 2019 <20><><EFBFBD><D7BC>"},
|
|||
|
{.Key = "WMDGN-G9PQG-XVVXX-R3X43-63DFG", .English = "Windows Server 2019 Datacenter", .Chinese = "Windows Server 2019 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>"},
|
|||
|
{.Key = "WVDHN-86M7X-466P6-VHXV7-YY726", .English = "Windows Server 2019 Datacenter Azure", .Chinese = "Windows Server 2019 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> Azure"},
|
|||
|
{.Key = "WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY", .English = "Windows Server 2016 Standard", .Chinese = "Windows Server 2016 <20><><EFBFBD><D7BC>"},
|
|||
|
{.Key = "CB7KF-BWN84-R7R2Y-793K2-8XDDG", .English = "Windows Server 2016 Datacenter", .Chinese = "Windows Server 2016 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>"},
|
|||
|
{.Key = "JCKRF-N37P4-C2D82-9YXRT-4M63B", .English = "Windows Server 2016 Datacenter Azure", .Chinese = "Windows Server 2016 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> Azure"},
|
|||
|
{.Key = "N2KJX-J94YW-TQVFB-DG9YT-724CC", .English = "Windows Server Standard Half Year", .Chinese = "Windows Server <20><><EFBFBD><D7BC> <20><><EFBFBD><EFBFBD>"},
|
|||
|
{.Key = "6NMRW-2C8FM-D24W7-TQWMY-CWH2D", .English = "Windows Server Datacenter Half Year", .Chinese = "Windows Server <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> <20><><EFBFBD><EFBFBD>"},
|
|||
|
{.Key = NULL, .English = NULL, .Chinese = NULL},
|
|||
|
};
|
|||
|
|
|||
|
int GetSystemLangLen(void);
|
|||
|
int GetSystemListLen(void);
|
|||
|
void TranslateApp(void);
|
|||
|
void RunSlmgrCommand(const char* command);
|
|||
|
void ExecActionCommand(void);
|
|||
|
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
|
|||
|
|
|||
|
char Buffer[256] = {0x00};
|
|||
|
|
|||
|
switch(Message) {
|
|||
|
// case WM_CREATE: {
|
|||
|
// // <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
// HICON hicon = (HICON)LoadImage(GetModuleHandleW(NULL), MAKEINTRESOURCE(IDI_ICON),
|
|||
|
// IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
|
|||
|
//
|
|||
|
// if (hicon)
|
|||
|
// {
|
|||
|
// SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon);
|
|||
|
// SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon);
|
|||
|
// } else {
|
|||
|
// MessageBox(NULL, "Failed to load icon!", "Error", MB_OK | MB_ICONERROR);
|
|||
|
// }
|
|||
|
// break;
|
|||
|
// }
|
|||
|
case WM_DESTROY: {
|
|||
|
PostQuitMessage(0);
|
|||
|
break;
|
|||
|
}
|
|||
|
case WM_COMMAND:
|
|||
|
// <20><><EFBFBD>ť<EEB0B4>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
if (LOWORD(wParam) == START_ACTION_BTN_ID) { // <20>жϰ<D0B6>ť<EFBFBD>Ƿ<C7B7><F1B1BBB5><EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ
|
|||
|
ActionInfo.Key = SystemVersionList[CurSystemVersion].Key;
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
GetWindowText(ActionServerAddr,Buffer,sizeof(Buffer));
|
|||
|
ActionInfo.ActionServer = Buffer;
|
|||
|
ExecActionCommand();
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
if (HIWORD(wParam) == CBN_SELCHANGE) {
|
|||
|
// <20>ж<EFBFBD><D0B6>ĸ<EFBFBD> ComboBox <20><>ѡ<EFBFBD><D1A1>
|
|||
|
HWND hComboBox = (HWND)lParam;
|
|||
|
|
|||
|
if (hComboBox == SystemLang)
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
CurSystemLang = SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
|
|||
|
|
|||
|
TranslateApp();
|
|||
|
|
|||
|
} else if (hComboBox == SystemVersion)
|
|||
|
{
|
|||
|
// ѡ<><D1A1>ϵͳ<CFB5>汾
|
|||
|
CurSystemVersion = SendMessage(hComboBox, CB_GETCURSEL, 0, 0);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ
|
|||
|
ActionInfo.Key = SystemVersionList[CurSystemVersion].Key;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
|
|||
|
default:
|
|||
|
return DefWindowProc(hwnd, Message, wParam, lParam);
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
/* Win32 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD> */
|
|||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
|||
|
|
|||
|
memset(&wc,0,sizeof(wc));
|
|||
|
wc.cbSize = sizeof(WNDCLASSEX);
|
|||
|
wc.lpfnWndProc = WndProc;
|
|||
|
wc.hInstance = hInstance;
|
|||
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|||
|
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
|||
|
wc.lpszClassName = "WindowClass";
|
|||
|
wc.hIcon = LoadIcon(hInstance, "A");
|
|||
|
wc.hIconSm = LoadIcon(hInstance, "A");
|
|||
|
|
|||
|
if(!RegisterClassEx(&wc)) {
|
|||
|
MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
hwnd = CreateWindowEx(
|
|||
|
WS_EX_CLIENTEDGE,
|
|||
|
"WindowClass",
|
|||
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Windows<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>v1.0",
|
|||
|
WS_VISIBLE | WS_OVERLAPPEDWINDOW,
|
|||
|
CW_USEDEFAULT, CW_USEDEFAULT, 450, 260,
|
|||
|
NULL, NULL, hInstance, NULL);
|
|||
|
|
|||
|
if(hwnd == NULL) {
|
|||
|
MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
SystemLang = CreateWindowEx(
|
|||
|
0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>ʽ
|
|||
|
"COMBOBOX", // ComboBox <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "COMBOBOX"
|
|||
|
NULL, // Ĭ<>ϱ<EFBFBD><CFB1><EFBFBD>
|
|||
|
CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL, // ComboBox <20><>ʽ
|
|||
|
INFO_LEFT_MARGIN, 10, // x, y λ<><CEBB>
|
|||
|
150, 200, // <20><><EFBFBD>Ⱥ߶<CDB8>
|
|||
|
hwnd, // <20><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
|||
|
0, // <20>ؼ<EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>
|
|||
|
hInstance, // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
NULL // <20><EFBFBD><DEB8>Ӳ<EFBFBD><D3B2><EFBFBD>
|
|||
|
);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
|||
|
for(int i = 0;i < GetSystemLangLen();i++){
|
|||
|
// <20><> ComboBox <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|||
|
SendMessage(SystemLang, CB_ADDSTRING, 0, (LPARAM)SystemLangList[i]);
|
|||
|
}
|
|||
|
|
|||
|
// Ĭ<><C4AC>ѡ<EFBFBD>е<EFBFBD>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1>
|
|||
|
SendMessage(SystemLang, CB_SETCURSEL, (WPARAM)0, 0);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5>б<EFBFBD>
|
|||
|
SystemVersion = CreateWindowEx(
|
|||
|
0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>ʽ
|
|||
|
"COMBOBOX", // ComboBox <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "COMBOBOX"
|
|||
|
NULL, // Ĭ<>ϱ<EFBFBD><CFB1><EFBFBD>
|
|||
|
CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL, // ComboBox <20><>ʽ
|
|||
|
INFO_LEFT_MARGIN, 50, // x, y λ<><CEBB>
|
|||
|
350, 500, // <20><><EFBFBD>Ⱥ߶<CDB8>
|
|||
|
hwnd, // <20><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
|||
|
1, // <20>ؼ<EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>
|
|||
|
hInstance, // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
NULL // <20><EFBFBD><DEB8>Ӳ<EFBFBD><D3B2><EFBFBD>
|
|||
|
);
|
|||
|
|
|||
|
// <20><>ϵͳ<CFB5>汾<EFBFBD><E6B1BE><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
|||
|
for(int i = 0;i < GetSystemListLen();i++){
|
|||
|
// <20><> ComboBox <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|||
|
SendMessage(SystemVersion, CB_ADDSTRING, 0, (LPARAM)SystemVersionList[i].English);
|
|||
|
}
|
|||
|
|
|||
|
// Ĭ<><C4AC>ѡ<EFBFBD>е<EFBFBD>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1>
|
|||
|
SendMessage(SystemVersion, CB_SETCURSEL, (WPARAM)0, 0);
|
|||
|
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ
|
|||
|
ActionServerText = CreateWindowEx(
|
|||
|
0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>ʽ
|
|||
|
"STATIC", // <20><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>
|
|||
|
ActionServerStr[CurSystemLang], // <20><>ǩ<EFBFBD>ı<EFBFBD>
|
|||
|
WS_VISIBLE | WS_CHILD, // <20><>ǩ<EFBFBD><C7A9>ʽ
|
|||
|
INFO_LEFT_MARGIN, 90, // x, y λ<><CEBB>
|
|||
|
150, 20, // <20><><EFBFBD>Ⱥ߶<CDB8>
|
|||
|
hwnd, // <20><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
|||
|
NULL, // <20>ؼ<EFBFBD>ID
|
|||
|
hInstance, // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
NULL // <20><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>
|
|||
|
);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༭<F2A3A8B1>ؼ<EFBFBD><D8BC><EFBFBD>
|
|||
|
ActionServerAddr = CreateWindowEx(
|
|||
|
0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>ʽ
|
|||
|
"EDIT", // <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
"kms.03k.org", // Ĭ<><C4AC><EFBFBD>ı<EFBFBD>
|
|||
|
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT, // <20><>ʽ
|
|||
|
INFO_LEFT_MARGIN, 120, // x, y λ<><CEBB>
|
|||
|
150, 24, // <20><><EFBFBD>Ⱥ߶<CDB8>
|
|||
|
hwnd, // <20><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
|||
|
NULL, // <20>ؼ<EFBFBD>ID
|
|||
|
hInstance, // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
NULL // <20><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>
|
|||
|
);
|
|||
|
|
|||
|
// <20><><EFBFBD>ť
|
|||
|
ActionBtn = CreateWindowEx(
|
|||
|
0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>ʽ
|
|||
|
"BUTTON", // <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>
|
|||
|
ActionBtnStr[CurSystemLang], // <20><>ť<EFBFBD>ı<EFBFBD>
|
|||
|
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // <20><>ť<EFBFBD><C5A5>ʽ
|
|||
|
INFO_LEFT_MARGIN, 160, // x, y λ<><CEBB>
|
|||
|
100, 30, // <20><><EFBFBD>Ⱥ߶<CDB8>
|
|||
|
hwnd, // <20><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
|||
|
START_ACTION_BTN_ID, // <20>ؼ<EFBFBD>ID
|
|||
|
hInstance, // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
NULL // <20><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>
|
|||
|
);
|
|||
|
|
|||
|
|
|||
|
// <20><>Ϣѭ<CFA2><D1AD>
|
|||
|
while(GetMessage(&msg, NULL, 0, 0) > 0) {
|
|||
|
TranslateMessage(&msg);
|
|||
|
DispatchMessage(&msg);
|
|||
|
}
|
|||
|
|
|||
|
return msg.wParam;
|
|||
|
}
|
|||
|
|
|||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
int GetSystemLangLen(void)
|
|||
|
{
|
|||
|
int SystemLangNum = 0x00;
|
|||
|
|
|||
|
while(1){
|
|||
|
if(SystemLangList[SystemLangNum] == NULL)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SystemLangNum++;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return (SystemLangNum);
|
|||
|
}
|
|||
|
|
|||
|
// <20><>ȡϵͳ<CFB5>汾<EFBFBD>б<EFBFBD><D0B1>ij<EFBFBD><C4B3><EFBFBD>
|
|||
|
int GetSystemListLen(void)
|
|||
|
{
|
|||
|
int SystemListNum = 0x00;
|
|||
|
|
|||
|
while(1){
|
|||
|
if(SystemVersionList[SystemListNum].Key == NULL)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SystemListNum++;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return (SystemListNum);
|
|||
|
}
|
|||
|
|
|||
|
// ִ<><D6B4>slmgr<67><72><EFBFBD><EFBFBD>
|
|||
|
void RunSlmgrCommand(const char* command)
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|||
|
char fullCommand[256];
|
|||
|
snprintf(fullCommand, sizeof(fullCommand), "cmd.exe /c %s", command);
|
|||
|
|
|||
|
// ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ShellExecute(NULL, "runas", "cmd.exe", fullCommand, NULL, SW_SHOWNORMAL);
|
|||
|
}
|
|||
|
|
|||
|
// <20><>װ<EFBFBD><D7B0>Կ
|
|||
|
void InstallKey(void)
|
|||
|
{
|
|||
|
char BaseCmd[256] = {"slmgr /ipk "};
|
|||
|
|
|||
|
snprintf(BaseCmd + strlen(BaseCmd), sizeof(BaseCmd) - strlen(BaseCmd), "%s", ActionInfo.Key);
|
|||
|
|
|||
|
RunSlmgrCommand(BaseCmd);
|
|||
|
|
|||
|
//MessageBox(hwnd, BaseCmd, "<22><>ʾ", MB_OK | MB_ICONINFORMATION);
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void SetActionServer(void)
|
|||
|
{
|
|||
|
char BaseCmd[256] = {"slmgr /skms "};
|
|||
|
|
|||
|
snprintf(BaseCmd + strlen(BaseCmd), sizeof(BaseCmd) - strlen(BaseCmd), "%s", ActionInfo.ActionServer);
|
|||
|
|
|||
|
RunSlmgrCommand(BaseCmd);
|
|||
|
|
|||
|
//MessageBox(hwnd, BaseCmd, "<22><>ʾ", MB_OK | MB_ICONINFORMATION);
|
|||
|
}
|
|||
|
|
|||
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|||
|
void StartAction(void)
|
|||
|
{
|
|||
|
char BaseCmd[256] = {"slmgr /ato "};
|
|||
|
|
|||
|
RunSlmgrCommand(BaseCmd);
|
|||
|
|
|||
|
//MessageBox(hwnd, BaseCmd, "<22><>ʾ", MB_OK | MB_ICONINFORMATION);
|
|||
|
}
|
|||
|
|
|||
|
// <20><>ʼִ<CABC>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void ExecActionCommand(void)
|
|||
|
{
|
|||
|
InstallKey();
|
|||
|
SetActionServer();
|
|||
|
StartAction();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӣ<EFBFBD><D3A2>
|
|||
|
void TranslateEnglish(void)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD>ϵͳ<CFB5>汾<EFBFBD>б<EFBFBD>
|
|||
|
SendMessage(SystemVersion, CB_RESETCONTENT, 0, 0);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><>ϵͳ<CFB5>汾<EFBFBD><E6B1BE><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
|||
|
for(int i = 0;i < GetSystemListLen();i++){
|
|||
|
// <20><> ComboBox <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|||
|
SendMessage(SystemVersion, CB_ADDSTRING, 0, (LPARAM)SystemVersionList[i].English);
|
|||
|
}
|
|||
|
|
|||
|
// <20>ļ<DEB8><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ǩ
|
|||
|
SendMessage(ActionServerText, WM_SETTEXT, 0, (LPARAM)ActionServerStr[CurSystemLang]);
|
|||
|
|
|||
|
// <20>ļ<DEB8><C4BC>ť<EEB0B4><C5A5><EFBFBD>ı<EFBFBD>
|
|||
|
SendMessage(ActionBtn, WM_SETTEXT, 0, (LPARAM)ActionBtnStr[CurSystemLang]);
|
|||
|
}
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void TranslateChinese(void)
|
|||
|
{
|
|||
|
SendMessage(SystemVersion, CB_RESETCONTENT, 0, 0);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><>ϵͳ<CFB5>汾<EFBFBD><E6B1BE><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
|||
|
for(int i = 0;i < GetSystemListLen();i++){
|
|||
|
// <20><> ComboBox <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|||
|
SendMessage(SystemVersion, CB_ADDSTRING, 0, (LPARAM)SystemVersionList[i].Chinese);
|
|||
|
}
|
|||
|
|
|||
|
// <20>ļ<DEB8><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ǩ
|
|||
|
SendMessage(ActionServerText, WM_SETTEXT, 0, (LPARAM)ActionServerStr[CurSystemLang]);
|
|||
|
|
|||
|
// <20>ļ<DEB8><C4BC>ť<EEB0B4><C5A5><EFBFBD>ı<EFBFBD>
|
|||
|
SendMessage(ActionBtn, WM_SETTEXT, 0, (LPARAM)ActionBtnStr[CurSystemLang]);
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void TranslateApp(void)
|
|||
|
{
|
|||
|
switch (CurSystemLang) {
|
|||
|
case ENGLISH:
|
|||
|
TranslateEnglish();
|
|||
|
break;
|
|||
|
case CHINESE:
|
|||
|
TranslateChinese();
|
|||
|
break;
|
|||
|
default:
|
|||
|
TranslateEnglish();
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
// Ĭ<><C4AC>ϵͳ<CFB5>汾ѡ<E6B1BE>е<EFBFBD>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1>
|
|||
|
SendMessage(SystemVersion, CB_SETCURSEL, (WPARAM)0, 0);
|
|||
|
}
|