我需要将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
答案 0 :(得分:1)
@crashmstr在评论中提供了答案,这是你在实践中如何做到这一点,假设函数想要返回指向你的指针。
WCHAR* ptr = NULL;
func(&ptr);
if(ptr) {
DoSomething(ptr);
...
MaybeYouHaveToFreeThePointer(ptr);
}