ATL Exe Server Passing array
-
Hi, I have created an ATL exe server which contains one interface. That interface contains one method. I passed an array of short from client side and is printing value of that array in server side. First value of array is correct but other values are worng. I find myself unable to get the reason. Please Help. Server Side ----------- [ object, uuid(40290173-0658-4414-9379-106D912396C2), dual, helpstring("IExeServer1 Interface"), pointer_default(unique) ] interface IExeServer1 : IDispatch { [id(1), helpstring("method Display")]HRESULT Display([in]short nCount, [in, size_is(nCount)] short *pnValue); }; Server side Implementation -------------------------- STDMETHODIMP CExeServer1::Display(short nCount, short *pnValue) { char szBuffer[20] = {0}; short int nCounter; for(nCounter = 0; nCounter < nCount; nCounter++) { sprintf(szBuffer, "%d", pnValue[nCounter]); MessageBox(NULL, szBuffer, "Message", MB_OK); } return(S_OK); } Client Side Implementation -------------------------- HRESULT hResult; IExeServer1 *pIExeServer = NULL; int iCounter = 0; short *pnValue = NULL; ::CoInitialize(NULL); hResult = CoCreateInstance(CLSID_ExeServer1, NULL, CLSCTX_LOCAL_SERVER, __uuidof(IExeServer1), reinterpret_cast(&pIExeServer)); if(SUCCEEDED(hResult)) { pnValue = reinterpret_cast(CoTaskMemAlloc(5 * sizeof(short))); for(iCounter = 0; iCounter < 5; iCounter++) { pnValue[iCounter] = iCounter + 1; } pIExeServer->Display(5, pnValue); CoTaskMemFree(pnValue); pIExeServer->Release(); } ::CoUninitialize(); Thanks Manish Rastogi