本文介绍了通过Windows C++接入游戏盾SDK的操作方法。

前提条件

已通过游戏盾控制台获取Windows版本的SDK包和AccessKey(即Appkey)。具体操作,请参见获取SDK和AccessKey下载SDK和AccessKey

操作步骤

  1. 在Windows上运行C++编译器。
  2. 新建一个console项目。示例中将项目命名为yxd_windows_sdk_test新建项目
  3. 配置Lib依赖。
    1. 在新建项目的目录下,新建libs目录。
    2. 将游戏盾Windows SDK中的YunCeng-WINDOWS.lib文件复制并粘贴到libs目录下。
    3. 打开项目的属性页,在链接器 > 常规中,添加./libs作为附加库目录附加库目录
    4. 链接器 > 输入中,添加YunCeng.WINDOWS.lib作为附加依赖项附加依赖项
  4. 加入头文件,编写测试代码。
    char appkey[] = "testgroupid";     
    eAlSdkRet ret = YunCeng_InitEx(appkey, "token");       
    if (ret != cAlSdkOK) {              
            printf("init sdk failed.\n");         
            return -1;    
       }
  5. YunCeng-WINDOWS.dll移动到项目可执行文件(示例中是yxd_windows_sdk_test.exe)所在目录。YunCeng-WINDOWS.dll
  6. 测试是否可以获取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);
       }