取当前实际生效的抓图模式、鼠标模式、键盘模式,返回一个逗号分隔的字符串,方便排障时确认现在到底走的是哪套输入方式。无参数。
本方法无需传入参数。
// 说明:本示例为完整 x64 控制台工程,整段复制覆盖新建控制台工程的 main.cpp 即可编译运行。
// 1. VS2019 新建「控制台应用」,项目属性 -> 平台选 x64,才能加载 64 位 DLL。
// 2. 项目属性 -> C/C++ -> 预编译头 -> 改为「不使用预编译头」,否则默认找 pch.h 会报 C1010。
// 3. 把 x64Game-Plug.dll 放到 exe 同目录(#import 与免注册加载都需要)。
// 4. 源码保存为 UTF-8 带 BOM,避免中文乱码。
#include <iostream>
#include <clocale>
#include <windows.h>
#include <comdef.h>
// 免注册加载:用 IGamePlug 智能指针装载
// rename 是为避开 windows.h 的 FindWindow 宏冲突,接口里的 FindWindow 在 C++ 侧改名为 FindWindowGP
#import "x64Game-Plug.dll" no_namespace rename("FindWindow", "FindWindowGP")
static HMODULE g_hDll = NULL;
static IGamePlugPtr g_plug;
static bool LoadPlug() {
const wchar_t* paths[] = {
L"x64Game-Plug.dll",
L"..\\x64Game-Plug.dll"
};
for (int i = 0; i < (int)(sizeof(paths) / sizeof(paths[0])); ++i) {
g_hDll = ::LoadLibraryW(paths[i]);
if (g_hDll) break;
}
if (!g_hDll) {
std::cout << "LoadLibrary failed: put x64Game-Plug.dll next to the exe" << std::endl;
return false;
}
typedef HRESULT (__stdcall *GamePlugCreateFn)(IGamePlug**);
GamePlugCreateFn fn = (GamePlugCreateFn)::GetProcAddress(g_hDll, "GamePlugCreate");
if (!fn) { std::cout << "GetProcAddress GamePlugCreate failed" << std::endl; return false; }
HRESULT hr = fn(&g_plug);
if (FAILED(hr)) { std::cout << "GamePlugCreate failed: 0x" << std::hex << hr << std::endl; return false; }
return true;
}
int main() {
if (!LoadPlug()) { system("pause"); return 1; }
// 授权(收费功能需先传入授权码,去 https://www.game-plug.cn/ 获取)
g_plug->SetUsername(_bstr_t(L"U12-XXXXXXXXXXXXXXXX"));
// ---------- 调用插件本命令方法如下 ----------
try {
_bstr_t mode = g_plug->GetInputMode();
std::wcout << L"当前输入模式: " << (const wchar_t*)mode << std::endl;
} catch (_com_error& e) {
std::wcout << L"COM error: " << e.ErrorMessage() << std::endl;
}
g_plug->Release();
system("pause");
return 0;
}
类型 string(BSTR),三段逗号分隔:抓图模式,鼠标模式,键盘模式。例如 gdi2,windows2,dx。dxlock 生效时末尾再加 ,lock(如 dx2,dx,dx,lock)。抓图取值:screen / gdi / gdi2 / dx2 / dx3 / dx2.1;键鼠取值:normal / windows / windows2 / windows3 / dx;未绑定时返回当前全局设置值。
1)排障时打印此值即可知道当前走的是哪套输入方式。2)返回的是当初填写的模式名(如 windows、dx2),便于和绑定参数对照。3)本功能为收费功能,调用前需 SetUsername 传入授权码(示例已含)。