Leaked source code of windows server 2003
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
HRESULT BuildVariantArrayofStrings( LPWSTR *lppPathNames, DWORD dwPathNames, VARIANT ** ppVar ) {
VARIANT v; VARIANT * pVar = NULL; SAFEARRAYBOUND sabNewArray; DWORD i; SAFEARRAY *psa = NULL; HRESULT hr;
*ppVar = NULL; sabNewArray.cElements = dwPathNames; sabNewArray.lLbound = 0; psa = SafeArrayCreate(VT_VARIANT, 1, &sabNewArray);
if (!psa) { goto Fail; }
for (i = 0; i < dwPathNames; i++) {
VariantInit(&v); V_VT(&v) = VT_BSTR; V_BSTR(&v) = *(lppPathNames + i); hr = SafeArrayPutElement(psa, (long FAR *)&i, &v ); }
pVar = (VARIANT *)AllocSplMem(sizeof(VARIANT));
if (!pVar) { goto Fail; }
V_VT(pVar) = VT_VARIANT | VT_ARRAY;
V_ARRAY(pVar) = psa;
return(ResultFromScode(S_OK));
Fail:
if (pVar) { FreeSplMem(pVar); }
if (psa) { SafeArrayDestroy(psa); }
*ppVar = pVar;
return(E_FAIL);
}
HRESULT BuildVariantArrayofIntegers( LPDWORD lpdwObjectTypes, DWORD dwObjectTypes, VARIANT ** ppVar ) {
VARIANT v; VARIANT * pVar = NULL; SAFEARRAYBOUND sabNewArray; DWORD i; SAFEARRAY *psa = NULL; HRESULT hr;
*ppVar = NULL; sabNewArray.cElements = dwObjectTypes; sabNewArray.lLbound = 0; psa = SafeArrayCreate(VT_VARIANT, 1, &sabNewArray);
if (!psa) { goto Fail; }
for (i = 0; i < dwObjectTypes; i++) {
VariantInit(&v); V_VT(&v) = VT_I4; V_I4(&v) = *(lpdwObjectTypes + i); hr = SafeArrayPutElement(psa, (long FAR *)&i, &v ); }
pVar = (VARIANT *)AllocSplMem(sizeof(VARIANT));
if (!pVar) { goto Fail; }
V_VT(pVar) = VT_VARIANT | VT_ARRAY;
V_ARRAY(pVar) = psa;
*ppVar = pVar; return(ResultFromScode(S_OK));
Fail:
if (pVar) { FreeSplMem(pVar); }
if (psa) { SafeArrayDestroy(psa); }
return(E_FAIL); }
|