Need Com Help - I'm a beginner
-
I have these 2 lines of code, if I remark them out, my function runs fine, but does not add the data to the metabase key. If I leave them in, I can't unload the Variant Array, and I get a CRT Heap Failure upon exiting the function. I sort of know what it does, it takes the new array entry and converts the type to VT_DISPATCH, and then copies the CLASS MimeMap into the array's last entry. I have worked hard to get the complete function to work, and it does, it generates the MimeMap Key, loads the data, but I can't exit the function clean, and call it again. If I need to post more, let me know.
V_VT(&va.pa[cVariants]) = VT_DISPATCH;
V_DISPATCH(&va.pa[cVariants]) = pME;
++cVariants; -
I have these 2 lines of code, if I remark them out, my function runs fine, but does not add the data to the metabase key. If I leave them in, I can't unload the Variant Array, and I get a CRT Heap Failure upon exiting the function. I sort of know what it does, it takes the new array entry and converts the type to VT_DISPATCH, and then copies the CLASS MimeMap into the array's last entry. I have worked hard to get the complete function to work, and it does, it generates the MimeMap Key, loads the data, but I can't exit the function clean, and call it again. If I need to post more, let me know.
V_VT(&va.pa[cVariants]) = VT_DISPATCH;
V_DISPATCH(&va.pa[cVariants]) = pME;
++cVariants;How many elements does
va.pa
own. The heap failure is probably occurring because you're exceeding the bounds of the array when you do++cVariants
.«_Superman_» _I love work. It gives me something to do between weekends.
-
How many elements does
va.pa
own. The heap failure is probably occurring because you're exceeding the bounds of the array when you do++cVariants
.«_Superman_» _I love work. It gives me something to do between weekends.
I thought about that. If the mime map key is empty at 0, I add an entry, the +CVariants becomes 1. In the For Loop SafeArrayPutElement, it loops once. so no existing data, add pME, va.pa = {pa=0x003a7200 DISPATCH = 0x017a8458 } vt = 9, cVariants = 0 the added data is the 0, first array entry, but makes the SafeArray Bound 1, because it can't be 0? So you don't think that my pME is distorting the va.pa?, I can't see the data, so I don't know. I'm in Antarctica here on this one, it's not a popular subject, and wrappers have been created to do the job in VB. I'm learning that super hard stuff has been replaced with high level wrappers by MS. Thanks for looking at my post, I really need to pull this off, and move on to my socket issue. I think I'm so close to finishing this function.
if (NULL != pwszAddExtension && NULL != pwszAddType) {
CComPtr<IISMimeType> pME;// Build a CCom Pointer and Instance hr = pME.CoCreateInstance(L"MimeMap"); RETURN\_ON\_FAILURE(hr); hr = pME->put\_Extension(bstrAddExtension); hr = pME->put\_MimeType(bstrAddType); RETURN\_ON\_FAILURE(hr); // Append pME to the array //V\_VT(&va.pa\[cVariants\]) = VT\_DISPATCH; //V\_DISPATCH(&va.pa\[cVariants\]) = pME; //++cVariants; <- You talkin about this- if 0, then add 1 SAFEARRAYBOUND saBound = {cVariants, 0}; SafeArray sa(VT\_VARIANT, 1, &saBound); ,- the bound becomes 1 VARIANT varArray; VariantInit(&varArray); V\_VT(&varArray) = (VT\_VARIANT | VT\_ARRAY); V\_ARRAY(&varArray) = sa.psa; for (i = 0; i < cVariants; ++i) { hr = SafeArrayPutElement(sa.psa, &i, &va.pa\[i\]); RETURN\_ON\_FAILURE(hr); }
-
How many elements does
va.pa
own. The heap failure is probably occurring because you're exceeding the bounds of the array when you do++cVariants
.«_Superman_» _I love work. It gives me something to do between weekends.
Oh wow your a genius. Over all in the end, the cVariants value was wrong when the first array called va was created. It was too small, so the one you pointed out added a value that was not initialized, it ncreased the size of the array, in a space that was too small. So that's why the delete [] va crashed. So finally after week of messing with this, I broke the program down in 2, worked on the add mime until it was clean, and just added the code to read the current mimes. I put much weight on your suggestion, but did keep it in mind. Thanks Superman.