> FUNCTION GetFBDBlob(nFileID AS Integer, aBlobData AS Variant ) AS Integer >>This works with the VFP client when I call with a reference to a char array, like so:
> DIMENSION aBlobData[nFileSize] AS char > nResult = oFBD.GetFBDBlob(nFileID, @aBlobData) >>
> SAFEARRAY* pSA = SafeArrayCreateVectorEx(VT_UI1, 0, nFileSize, NULL); > VARIANT vaBlobData; > VariantInit(&vaBlobData); > vaBlobData.vt = VT_ARRAY | VT_BYREF | VT_UI1; > vaBlobData.pparray = &pSA; > lResult = pFBDDBA->GetFBDBlob(nFileID, vaBlobData); >>
> SAFEARRAY* pSA = SafeArrayCreateVectorEx(VT_UI1, 0, nFileSize, NULL); > VARIANT vaBlobData; > VariantInit(&vaBlobData); > vaBlobData.vt = VT_ARRAY | VT_UI1; > vaBlobData.parray = pSA; > lResult = pFBDDBA->GetFBDBlob(nFileID, vaBlobData); >>
//These 2 macros make it easier to call methods on VFP servers. #define XDOCMD(cmd) v1 = cmd;v2 = pmyclass->mydocmd(&v1); #define XDOMETH(meth, cmd) v1 = cmd; v2 = pmyclass->##meth(&v1) int CThreadObj::VirtualThreadStart() { char szBuf[1000]; int i; CoInitialize(0); using namespace myserver; ImyclassPtr pmyclass; // declare a smart ptr to the server pmyclass.CreateInstance("myserver.myclass"); _variant_t v1,v2; long vfpthreadid; XDOCMD("declare integer GetCurrentThreadId in win32api"); for (i = 0 ; i < NUMITER ; i++) { //ask the server for the thread ID XDOMETH(myeval,"GetCurrentThreadId()"); vfpthreadid = v2.lVal; wsprintf(szBuf, "i = %d Thread # %d ID = %d VFPID = %d\n", i,m_nthread,m_threadId, vfpthreadid); //show the output in the VC Output Window OutputDebugString(szBuf); } pmyclass = 0; // release the server CoUninitialize(); return 0; } //this is the static real thread starting proc unsigned long __stdcall CThreadObj::RealThreadStart(void *p) { CThreadObj *pobj; //get a pointer to the thread object pobj = (CThreadObj *) p; // and call it's thread start routine pobj->VirtualThreadStart(); return 0; } int WINAPI WinMain(HINSTANCE , HINSTANCE , LPSTR , int ) { CThreadObj threads[NUMTHREADS]; //decl array of CThreadObj objects HANDLE harray[NUMTHREADS]; //array of handles for (int i = 0 ; i < NUMTHREADS ; i++) { threads[i].m_nthread = i; //record the thread # harray[i] = //record the thread ID CreateThread(NULL,0, CThreadObj::RealThreadStart, //thd strt addr (void *)&threads[i], //parm to pass to thrd NULL, &threads[i].m_threadId); } //now wait for all the threads to finish WaitForMultipleObjects(NUMTHREADS, harray, TRUE, INFINITE); return 0; }