呼叫symbol的 ssiconnect.ocx 時遇到其中一個函式
typedef /* [wire_marshal] */ struct tagVARIANT VARIANT;
long __fastcall GetDecodeData(VARIANT* DecodeData, short Type, short* SSICode);
而在VC例程中DecodeData使用的是COleSafeArray這個型別。搗鼓了好久也沒弄明白,在BCB中有那個可以代替這個變數呢
COleSafeArray sa;
COleSafeArray *psa = &sa;
unsigned char *ptmpbuf;
short code;
sa.Clear();
m_ssi.GetDecodeData(psa,VT_UI1, &code );
uj5u.com熱心網友回復:
COleSafeArray是從VARIANT繼承來的,可以用VARIANT物件代入。uj5u.com熱心網友回復:
我直接用VARIANT對像,但沒有回傳值呢 COleSafeArray應該是個安全陣列 :tagVARIANT varChunk;
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].cElements = 100;
rgsabound[0].lLbound = 0;
psa = SafeArrayCreate(VT_UI1,1,rgsabound);
varChunk.vt = VT_ARRAY|VT_UI1;
varChunk.parray = psa;
short tt;
SafeArrayLock(psa);
long len=SSIConnect1->GetDecodeData(&varChunk,VT_UI1,&tt);
SafeArrayUnlock(psa);
unsigned char pReceData[512];
memset(pReceData,0,sizeof(pReceData));
long i=0;
strcpy(pReceData,(unsigned char *)varChunk.parray->pvData);
SafeArrayDestroy(psa);
仍然不行 請賜教
uj5u.com熱心網友回復:
GetDecodeData以后,回傳值len是多少?OCX的開發方有沒有提供檔案什么的?uj5u.com熱心網友回復:
len一直回傳0 正常應該回傳掃描資料的長度。Visual Basic programmers will set the Type parameter to vbString. VC++ programmers can set the parameter to VT_BSTR or they may wish to set it to VT_UI1 if DecodeData is expected to contain binary data.
另一個檔案上:
he type specifier is needed because although Visual Basic programs may manipulate the
data using a vbString, Visual C++ programmers use a data type specifier of VT_UI1, and
DecodeData would be a pointer to ColeSafeArray, allowing the returned data to be
manipulated as an array of unsigned character.
uj5u.com熱心網友回復:
我試過在Vb上確實能回傳正確數值,我故意把引數vbString改為其他值,回傳值就成0了。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/154247.html
上一篇:請教一個關于C++ Builder 呼叫 web services 的問題
下一篇:Qt菜鳥請教大神
