BOOL CXLAutomation::AddArgumentBool(LPOLESTR lpszArgName, WORD wFlags, BOOL b) { AddArgumentCommon(lpszArgName, wFlags, VT_BOOL); // Note the variant representation of True as -1 m_aVargs[m_iArgCount++].boolVal = b ? -1 : 0; return TRUE; }
BOOL AddArgumentCString(LPOLESTR lpszArgName, WORD wFlags,LPOLESTR lpsz) { BSTR b; b = SysAllocString(lpsz); if (!b) return FALSE; AddArgumentCommon(lpszArgName, wFlags, VT_BSTR); g_aVargs[g_iArgCount++].bstrVal = b; return TRUE; }
BOOL CXLAutomation::AddArgumentCString(LPOLESTR lpszArgName, WORD wFlags, CString szStr) { BSTR b; b = szStr.AllocSysString(); if (!b) return FALSE; AddArgumentCommon(lpszArgName, wFlags, VT_BSTR); m_aVargs[m_iArgCount++].bstrVal = b; return TRUE; }
/* * Constructs an 1-dimensional array containing variant strings. The strings * are copied from an incoming array of C-Strings. */ BOOL CXLAutomation::AddArgumentCStringArray(LPOLESTR lpszArgName, WORD wFlags, LPOLESTR *paszStrings, int iCount) { SAFEARRAY *psa; SAFEARRAYBOUND saBound; VARIANTARG *pvargBase; VARIANTARG *pvarg; int i, j; saBound.lLbound = 0; saBound.cElements = iCount; psa = SafeArrayCreate(VT_VARIANT, 1, &saBound); if (psa == NULL) return FALSE; SafeArrayAccessData(psa, (void**) &pvargBase); pvarg = pvargBase; for (i = 0; i < iCount; i++) { // copy each string in the list of strings ClearVariant(pvarg); pvarg->vt = VT_BSTR; if ((pvarg->bstrVal = SysAllocString(*paszStrings++)) == NULL) { // memory failure: back out and free strings alloc'ed up to // now, and then the array itself. pvarg = pvargBase; for (j = 0; j < i; j++) { SysFreeString(pvarg->bstrVal); pvarg++; } SafeArrayDestroy(psa); return FALSE; } pvarg++; } SafeArrayUnaccessData(psa); // With all memory allocated, setup this argument AddArgumentCommon(lpszArgName, wFlags, VT_VARIANT | VT_ARRAY); m_aVargs[m_iArgCount++].parray = psa; return TRUE; }
BOOL CXLAutomation::AddArgumentDouble(LPOLESTR lpszArgName, WORD wFlags, double d) { AddArgumentCommon(lpszArgName, wFlags, VT_R8); m_aVargs[m_iArgCount++].dblVal = d; return TRUE; }
BOOL CXLAutomation::AddArgumentInt2(LPOLESTR lpszArgName, WORD wFlags, int i) { AddArgumentCommon(lpszArgName, wFlags, VT_I2); m_aVargs[m_iArgCount++].iVal = i; return TRUE; }
BOOL CXLAutomation::AddArgumentDispatch(LPOLESTR lpszArgName, WORD wFlags, IDispatch * pdisp) { AddArgumentCommon(lpszArgName, wFlags, VT_DISPATCH); m_aVargs[m_iArgCount++].pdispVal = pdisp; return TRUE; }