2

我看到了这个函数,想知道如何调用它。我可能想编写一个组件并将这个函数导出到 COM 客户端,所以我想填充一个安全的字符串数组(其他自动化类型也可以)。所以我想利用 ATL 智能类。这就是我目前所拥有的,一个控制台应用程序。

#include "pch.h"
#include <iostream>
// in pch.h ...
//#include "windows.h"
//#include "comutil.h"
//#include "atlbase.h"
//#include <comdef.h>
//#include "atlsafe.h"


int main()
{
    LCID germany(7);
    LPOLESTR *rgp;
    HRESULT hr;
    hr=::GetAltMonthNames(germany, &rgp); // can't see results
    if (hr != S_OK) return hr;

    CComSafeArray<BSTR> months;
    hr = ::GetAltMonthNames(germany,(LPOLESTR**) &months); //forced compile but no joy
    if (hr != S_OK) return hr;
    std::cout << "Hello World!\n"; 
}
4

1 回答 1

3

您的第一个代码没问题,但没有定义德语的替代名称。试试波兰语:

LPOLESTR* rgp;
if (SUCCEEDED(GetAltMonthNames(1045, &rgp)))
{
    int i = 0;
    while (rgp[i])
    {
        wprintf(L"%s\n", rgp[i++]);
    }
}

文档说:

用于回历、波兰语和俄语的备用月份名称。

于 2019-06-11T13:50:43.353 回答