【问题标题】:NSIS popstring fills only one characterNSIS popstring 只填充一个字符
【发布时间】:2018-02-04 16:02:33
【问题描述】:

我尝试从 NSIS 调用中读取参数,例如:

MySQL::SetCredentials "localhost" 3306 "banananode" "root" ""

在方法上,我尝试使用popstring 获取第一个参数,就像 NSIS 上的示例代码一样:

LPTSTR mystringbuffer = (LPTSTR)GlobalAlloc(GPTR, (3 + string_size + 1) * sizeof(*mystringbuffer));
int test = popstring(mystringbuffer);
MessageBox(hWnd, mystringbuffer, TEXT("plug-in"), MB_OK);
GlobalFree(mystringbuffer);

但是popstring 只返回l 而不是localhost

我曾尝试使用 getuservariable(INST_0) 作为示例,但在这里,它给了我一个空结果。

你能告诉我,有什么问题吗?

【问题讨论】:

    标签: c++ nsis nsis-plugin


    【解决方案1】:

    这与the problem you had earlier 正好相反。您仍在混合和匹配 ANSI 和 Unicode 字符串/函数。单个字母意味着您将 Unicode 字符串读取为 ANSI 字符串。 L"localhost" (l\0o\0c\0a\0l\0h\0o\0s\0t\0\0\0) 作为 ANSI 字符串只是 "l" (l\0)。

    也许这会减少混乱:

    void __declspec(dllexport) test(HWND hWndParent, ...)
    {
      MessageBox(hWndParent, sizeof(OSVERSIONINFOA) < sizeof(OSVERSIONINFO) ? TEXT("Unicode plug-in") : TEXT("ANSI plug-in"), TEXT("I'm a"), 0);
    }
    

    Section 
    !if "${NSIS_CHAR_SIZE}" > 1
      MessageBox mb_ok "Unicode installer"
    !else
      MessageBox mb_ok "ANSI installer"
    !endif
    myplugin::test
    SectionEnd
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-24
      • 1970-01-01
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-29
      相关资源
      最近更新 更多