【问题标题】:How to retrieve Steam username using SteamWorks API?如何使用 SteamWorks API 检索 Steam 用户名?
【发布时间】:2016-05-18 18:53:25
【问题描述】:

如何使用 Steam API(已启动并正在运行)在我的应用程序中获取当前使用(登录)帐户的 Steam 用户名。

Steam id 可以(例如)通过以下方式获得:

CSteamID id = SteamUser.GetSteamID();

但是我找不到获取用户名的方法。

【问题讨论】:

    标签: steam steamworks-api


    【解决方案1】:

    帐户名称

    据我所知,没有 API 函数,因此获取帐户名很困难。
    但是<SteamInstallPath>/config 文件夹中有一个SteamAppData.vdf 文件,看起来类似于:

    "SteamAppData"
    {
        "RememberPassword"  "<0|1>"
        "AutoLoginUser"     "<accountName>"
    }
    

    您可以使用steam_api.h 中定义的SteamAPI_GetSteamInstallPath() 命令获取 Steam 安装路径。
    然后您可以读取文件并从中提取帐户名称。

    玩家姓名

    获取玩家名字真的很简单:

    isteamfriends.h 你会找到这个方法:

    // returns the local players name - guaranteed to not be NULL.
    // this is the same name as on the users community profile page
    // this is stored in UTF-8 format
    // like all the other interface functions that return a char *, it's important that this pointer is not saved
    // off; it will eventually be free'd or re-allocated
    virtual const char *GetPersonaName() = 0;
    

    所以SteamFriends.GetPersonaName()应该给你玩家的名字。

    【讨论】:

    • 是否还需要用这个方法来获取Account Name,还是我们现在有了API函数?
    【解决方案2】:

    SteamFriends()->GetPersonaName();

    【讨论】:

      猜你喜欢
      • 2015-09-01
      • 1970-01-01
      • 2018-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-09
      • 2015-07-03
      • 2018-05-16
      相关资源
      最近更新 更多