Skip to content

Improve COM ctor exception code for failing ProgIDs #17673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Feb 2, 2025

The $module_name of com::__construct() can be a ProgID, ClassID or moniker. We first try CLSIDFromString(), and if that fails, we go ahead and try to treat the $module_name as a moniker. If that also fails, we throw an exception with the result of MkParseDisplayName() what would just be MK_E_SYNTAX if given a ProgID. This result is highly confusing for the common case where a ProgID is given, which is not registered (e.g. due to a typo). In this case, we use the original HRESULT (CO_E_CLASSSTRING) instead.

The `$module_name` of `com::__construct()` can be a ProgID, ClassID or
moniker.  We first try `CLSIDFromString()`, and if that fails, we go
ahead and try to treat the `$module_name` as a moniker.  If that also
fails, we throw an exception with the result of `MkParseDisplayName()`
what would just be `MK_E_SYNTAX` if given a ProgID.  This result is
highly confusing for the common case where a ProgID is given, which is
not registered (e.g. due to a typo).  In this case, we use the original
`HRESULT` (`CO_E_CLASSSTRING`) instead.
@cmb69 cmb69 changed the title Improve COM ctr exception code for failing ProgIDs Improve COM ctor exception code for failing ProgIDs Feb 2, 2025
@cmb69 cmb69 merged commit 252b52a into php:master Feb 14, 2025
9 checks passed
@cmb69 cmb69 deleted the cmb/com-ctor-hresult branch February 14, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant