Understanding WCHAR**
Understanding WCHAR**
本文关键字:WCHAR Understanding 更新时间:2023-10-16
我需要传递WCHAR**
类型变量来函数。我希望这个函数会给这个变量一些文本。但WCHAR**
到底是什么?根据我的理解WCHAR*
是指向数组WCHAR
指针。 那么WCHAR*
数组WCHAR**
呢?
如何初始化此变量?
WCHAR** c;
void func (WCHAR** s)
{
}
编译器很生气,认为c
没有初始化。如何处理?
这是从 wsdl 生成的用于 Web 服务的真实函数。我需要传递cConfig
变量。
HRESULT WINAPI WSHttpBinding_ISupportService_ConfigToClient(
__in WS_SERVICE_PROXY* _serviceProxy,
__in int clientId,
__out int* ConfigToClientResult,
__inout_opt __deref __nullterminated WCHAR** cConfig,
__in WS_HEAP* _heap,
__in_ecount_opt(_callPropertyCount) const WS_CALL_PROPERTY* _callProperties,
__in const ULONG _callPropertyCount,
__in_opt const WS_ASYNC_CONTEXT* _asyncContext,
__in_opt WS_ERROR* _error)
{
void* _argList[3];
_argList[0] = &clientId;
_argList[1] = &ConfigToClientResult;
_argList[2] = &cConfig;
return WsCall(_serviceProxy,
(WS_OPERATION_DESCRIPTION*)&tempuri_org_wsdlLocalDefinitions.contracts.WSHttpBinding_ISupportService.WSHttpBinding_ISupportService_ConfigToClient.WSHttpBinding_ISupportService_ConfigToClient,
(const void **)&_argList,
_heap,
_callProperties,
_callPropertyCount,
_asyncContext,
_error);
}
const _tempuri_org_wsdl tempuri_org_wsdl =
{
{// messages
{ // message description for ISupportService_LogIt_InputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_LogIt_InputMessageactionName, // http://tempuri.org/ISupportService/LogIt
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.LogIt,
}, // message description for ISupportService_LogIt_InputMessage
{ // message description for ISupportService_LogIt_OutputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_LogIt_OutputMessageactionName, // http://tempuri.org/ISupportService/LogItResponse
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.LogItResponse,
}, // message description for ISupportService_LogIt_OutputMessage
{ // message description for ISupportService_getClientId_InputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_getClientId_InputMessageactionName, // http://tempuri.org/ISupportService/getClientId
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.getClientId,
}, // message description for ISupportService_getClientId_InputMessage
{ // message description for ISupportService_getClientId_OutputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_getClientId_OutputMessageactionName, // http://tempuri.org/ISupportService/getClientIdResponse
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.getClientIdResponse,
}, // message description for ISupportService_getClientId_OutputMessage
{ // message description for ISupportService_GetClientCommands_InputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_GetClientCommands_InputMessageactionName, // http://tempuri.org/ISupportService/GetClientCommands
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.GetClientCommands,
}, // message description for ISupportService_GetClientCommands_InputMessage
{ // message description for ISupportService_GetClientCommands_OutputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_GetClientCommands_OutputMessageactionName, // http://tempuri.org/ISupportService/GetClientCommandsResponse
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.GetClientCommandsResponse,
}, // message description for ISupportService_GetClientCommands_OutputMessage
{ // message description for ISupportService_ConfigToSrv_InputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_ConfigToSrv_InputMessageactionName, // http://tempuri.org/ISupportService/ConfigToSrv
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.ConfigToSrv,
}, // message description for ISupportService_ConfigToSrv_InputMessage
{ // message description for ISupportService_ConfigToSrv_OutputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_ConfigToSrv_OutputMessageactionName, // http://tempuri.org/ISupportService/ConfigToSrvResponse
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.ConfigToSrvResponse,
}, // message description for ISupportService_ConfigToSrv_OutputMessage
{ // message description for ISupportService_ConfigToClient_InputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_ConfigToClient_InputMessageactionName, // http://tempuri.org/ISupportService/ConfigToClient
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.ConfigToClient,
}, // message description for ISupportService_ConfigToClient_InputMessage
{ // message description for ISupportService_ConfigToClient_OutputMessage
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.ISupportService_ConfigToClient_OutputMessageactionName, // http://tempuri.org/ISupportService/ConfigToClientResponse
(WS_ELEMENT_DESCRIPTION*)&tempuri_org_xsd.globalElements.ConfigToClientResponse,
}, // message description for ISupportService_ConfigToClient_OutputMessage
}, // messages
{// contracts
{ // WSHttpBinding_ISupportService
5,
(WS_OPERATION_DESCRIPTION**)tempuri_org_wsdlLocalDefinitions.contracts.WSHttpBinding_ISupportService.operations,
}, // end of WSHttpBinding_ISupportService
}, // contracts
{ // policies
{ // template description for WSHttpBinding_ISupportService
{ // channel properties
(WS_CHANNEL_PROPERTY*)&tempuri_org_wsdlLocalDefinitions.policies.WSHttpBinding_ISupportService.channelPropertiesArray,
3,
},
}, // end of template description
}, // policies
{ // endpointReferences
{ // WSHttpBinding_ISupportService
{ // endpointAddressDescription
WS_ADDRESSING_VERSION_1_0,
},
(WS_XML_STRING*)&tempuri_org_wsdlLocalDefinitions.dictionary.xmlStrings.WSHttpBinding_ISupportServiceendpointReferenceString, // <wsa10:EndpointReference xmlns:wsa10="http://www.w3.org/2005/08/addressing">...
}, // endof WSHttpBinding_ISupportService
}, // endof endpointReferences
}; // end of _tempuri_org_wsdl
@crashmstr注释
中提供了答案,以下是您在实践中的做法,假设函数想要返回指向您的指针。
WCHAR* ptr = NULL;
func(&ptr);
if(ptr) {
DoSomething(ptr);
...
MaybeYouHaveToFreeThePointer(ptr);
}
相关文章:
- MacOS通过在莫哈韦"wchar.h"下破碎的自制啤酒发出叮当声
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- 'const char*'和'WCHAR*'
- 为什么需要与 WCHAR 相关的代码处理
- 无法使用 mingw-w64 g++ 编译:找不到 <wchar.h>
- 无法将参数 1 从 WCHAR 转换为常量字符 *
- 无法使用 swprintf 在 WCHAR* 中打印字符*
- -fshort-wchar 和 std::wstring - 分段错误
- SFINAE: Understanding void_t and detect_if
- 我应该使用 wchar 还是 char 来加密?
- 【MacOSX 10.15.1】使用 odb 生成数据库,致命错误:wchar.h:没有这样的文件或目录 #include < wchar.h>
- 如何在 C++ 中的 wcstok 中使用常量 WCHAR* 变量?
- Understanding void func(A())
- 将字符串文本常量定义为 char const* 和 wchar const*
- 比较嵌套 for 循环中的两个 wchar 数组?
- wchar 模式下 pugixml 的链接错误
- strcmp 错误'WCHAR [260]' 'const char *'
- 'Cannot add two pointers'添加带有 WCHAR 的 LPCWSTR
- 如何将CString转换为使用WCHAR的Windows API和自定义函数?
- Understanding WCHAR**