xloper12变量xltype = str使用宽字符

发布于 2025-01-22 08:30:56 字数 517 浏览 3 评论 0原文

我试图注册一些功能并取得成功,直到字符串的长度超过255。我已经写了以下功能来循环浏览参数列表并转换L“ xxparametersxx”。对于任何字符串< 255个字符,它可以正常工作,但是当我到达256个字符串时,它不会输入第一个条目中字符#的相应代码。有人在这里有任何想法吗?

Joe

功能代码:

XLOPER12 CreateXLOPER12FromWStr(LPCWSTR cInput)

    XLOPER12 lpx;

    size_t len;

    len = wcslen(cInput);   wchar_t* lps = (wchar_t *)malloc((len + 2) * sizeof(wchar_t));

    lps[0] = (wchar_t)(len+2);

    wmemcpy_s(lps + 1, len, cInput, len);   lpx.xltype = xltypeStr;     lpx.val.str = lps;

    return lpx;

I am trying to register some functions and have success up until the length of my string exceeds 255. I have written the below function to cycle through the list of parameters and convert the L"xxparametersxx". For any string <255 characters it works fine but when I get to the 256 character string it does not enter the corresponding code for the # of characters in the first entry. Would anyone have any ideas here please?

Joe

Function Code:

XLOPER12 CreateXLOPER12FromWStr(LPCWSTR cInput)

    XLOPER12 lpx;

    size_t len;

    len = wcslen(cInput);   wchar_t* lps = (wchar_t *)malloc((len + 2) * sizeof(wchar_t));

    lps[0] = (wchar_t)(len+2);

    wmemcpy_s(lps + 1, len, cInput, len);   lpx.xltype = xltypeStr;     lpx.val.str = lps;

    return lpx;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丘比特射中我 2025-01-29 08:30:56

您上面的功能看起来有效(除了缺少括号!),我可以运行它,尽管我不确定为什么您将len+2 放入lps [0]:只有弦长就足够了。如果您使用的是xlfregister

  • 逗号分隔的参数名称的总长度必须为&lt; 256个字符
  • 帮助字符串必须为&lt; 256个字符
  • 函数名称必须为&lt; 256 chars

尽管Xloper12类型允许允许更长的字符串。

我不建议其他人直接使用C API:而是使用我的库xloil 详细信息如上所述,并添加了com,gui&amp; RTD支持。或使用 keith的Xlladdins

Your function above appears valid (except missing braces!) and I can run it, although I'm not sure why you put len+2 into lps[0]: just the string length is sufficient. You may be hitting other limitations downstream, if you are using xlfRegister:

  • The total length of comma-separated parameter names must be < 256 chars
  • Help strings must be < 256 chars
  • Function name must be < 256 chars

This is despite the XLOPER12 type allowing for considerably longer strings.

I don't recommend that anyone else use the C API directly: rather use my library xlOil which hides implementation details like the above and adds COM, GUI & RTD support. Or use Keith's xlladdins.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文