views:

119

answers:

1

UPDATED

I'm trying to programmatic-ally set a COM+ component's ConstructorString with a value for later initialization.

The code in question works fine on WinXP, Win2k3, Vista and Win2k8.

I'm failing on Win7 - Home Premium version.

I've determined by trial and error that there seems to be a size limit on the constructor string - if the string is 512 characters (wchar) or less, it saves. Longer, and the SaveChanges call on the CatalogCollection object fails with a 0x80110437 - COMADMIN_E_PROPERTYSAVEFAILED error.

Turns out, all systems have that limit - 512 characters.

We use CryptProtectData to encrypt a password before putting it into the string.

On win7 (x64) the output of the string is longer than on XP (x32) and W2k3 (x64).

So - CryptProtectData has changed - why is the output longer?

    if (!CryptProtectData(&dataIn,L" ",&optionalEntropy,NULL,NULL,
 CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN, &dataOut))
+1  A: 

What do you do with dataOut to turn it into a string? I can't remember the exact details now, but I assume the constructor string is a BSTR. dataOut is a byte buffer, so you need to be very careful when converting it to a string, so you don't trip on embedded NUL characters, etc.

Could you update your question to include the conversion from the output buffer of CryptProtectData to string?

Kim Gräsman
dataOut was turned to a string by turning the byte buffer into a numeric string sequence.I didn't write that part, but it looked like the byte was split into a powers of 16 character and a remainder character.This was doubling the dataOut to twice it's length - thus running out of space.I switched the code to use the ATL base64encode / base64decode calls instead - more efficient use of characters, and it fit inside of the string.I'd rather not include the logic of the string - it is proprietary code, but I admit it was flawed.
Eli
Lucky guess on my part, glad it helped!
Kim Gräsman