PHP如何从COM组件中获取返回的字符串?
COM组件中定义一个方法
HRESULT GetStr([in,out] BSTR* vStr, [in,out] LONG* vLen, [out,retval] LONG* vError);
方法实现为:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
STDMETHODIMP MC_MyClass::GetStr(BSTR* vStr, LONG* vLen, LONG* vError)
{
*vError = 0;
if(0 == vStr) return S_FALSE;
if(0 == vLen) return S_FALSE;
wchar_t tStr[] = L"This is a string from com!";
memcpy(*vStr, tStr, wcslen(tStr));
*vLen = wcslen(tStr);
*vError = 1;
return S_OK;
}
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> $tStr = ""; $tLen = 100; $tStr = str_pad($tStr, $tLen, "0"); $tRes = $tCom->GetStr(&$tStr, &$tLen);
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号