This topic describes how to use a C++ IDE to integrate a Windows SDK.

Prerequisites

  • You can obtain an SDK and AccessKey pair for Windows from the GameShield console. For more information, see Obtain an SDK package and AccessKey pair.
  • You can obtain the following information from the GameShield console.
    • GroupName: indicates a node group ID. Log on to the GameShield console, open the game management page, and view the target node group ID on the Basic Settings tab.Basic settings and a node group ID
    • Protection Target ID. Log on to the GameShield console, open the Games page, and view a protection target ID on the Protection Target Settings tab.Protection target settings and a protection target ID

Procedure

  1. Open a C++ editor in Windows.
  2. Create a project of the Console App type. Name the project yxd_windows_sdk_test.Create a project
  3. Add dependencies to the libs directory.
    1. Create a directory named libs in the new project directory.
    2. Copy the YunCeng-WINDOWS.lib file that resides in the Windows SDK to the libs directory.
    3. Open the Property page of the project, choose Linker > General, and add ./libs as an additional library directory.
    4. Choose Linker > Input, and add YunCeng.WINDOWS.lib as an additional dependency.
  4. Test the init method.
    char appkey[] = "appkey";
    eAlSdkRet ret = YunCeng_InitAlSdkEx(appkey, "Player ID");
    if (ret ! = cAlSdkOK) {
        printf("init sdk failed.\n");
        return -1;
    }
  5. Copy the .dll file to the directory where the project resides. Move YunCeng-WINDOWS.dll to the directory where the project executable file named yxd_windows_sdk_test.exe resides.YunCeng-WINDOWS.dll
  6. Check whether you can obtain the IP address of a protection target.
    //Call the key methods.
    ip_len = 18 
    ip = create_string_buffer('/0' * ip_len) 
    port_len = 18 
    port = create_string_buffer('/0' * port_len) 
    ret = YunCeng_GetProxyTcpByDomain("Player ID", "GroupName", "Protection target ID", "Port for the protection target", 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);
    }