本文介绍了通过Windows C++接入游戏盾SDK的操作方法。
操作步骤
- 在Windows上运行C++编译器。
- 新建一个console项目。示例中将项目命名为yxd_windows_sdk_test。
- 配置Lib依赖。
- 在新建项目的目录下,新建libs目录。
- 将游戏盾Windows SDK中的YunCeng-WINDOWS.lib文件复制并粘贴到libs目录下。
- 打开项目的属性页,在中,添加./libs作为附加库目录。
- 在中,添加YunCeng.WINDOWS.lib作为附加依赖项。
- 加入头文件,编写测试代码。
char appkey[] = "testgroupid";
eAlSdkRet ret = YunCeng_InitEx(appkey, "token");
if (ret != cAlSdkOK) {
printf("init sdk failed.\n");
return -1;
}
- 将YunCeng-WINDOWS.dll移动到项目可执行文件(示例中是yxd_windows_sdk_test.exe)所在目录。
- 测试是否可以获取IP。
/*
ret = YunCeng_GetProxyTcpByIp("token","groupId", "192.168.0.1","80", ip,ip_len, port,port_len); */
ret= YunCeng_GetProxyTcpByDomain("token","groupId", "aliyundoc.com","80", ip, ip_len, port,port_len);
if (ret != cAlSdkOK) {
printf("get next ip failed. \n");
} else {
printf("get next ip success. %s %s\n", ip, port);
}