OUT parameters
[OUT] parameters are always returned as reference and thus they are pointers. Caller should provide the address of the variable and called function should write the value of the variable in the address.
HRESULT ReturnChar(char *pchVal); HRESULT ReturnInt(int *pnVal); HRESULT ReturnLong(long *plVal); HRESULT ReturnFloat(float *pfVal); HRESULT ReturnDouple(int *pdVal); HRESULT hr; <type> variable; hr = ReturnType(&variable); if(hr == S_OK) { cout << "Returned value is << variable; } else { cout << "error: " << hr; }
dynamic OUT parameters
There could be string and malloc buffer or dynamic array for out variable. In those cases parameter has to be pointer to a pointer. Caller has to pass the address of the pointer variable. Calle or function should allocate a pointer or array buffer and this address value should be written to the caller provided address.
void ReturnString(char **pdVal); void ReturnPointer(void **pvVal); void ReturnBSTR(BSTR *pvVal); HRESULT hr; BSTR* varString; /* BSTR * or OLECHAR ** */ hr = ReturnType(&varString); if(hr == S_OK) { cout << "Returned value is << varString; /* Now free this sting, else memory leak */ SysFreeString (varString); } else { cout << "error: " << hr; }
About our authors: Team EQA
You have viewed 1 page out of 67. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.
Most popular
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Calculate weighted average
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Calculate weighted average