Search code examples
windowscomcom-interopoleprogid

What happens if I violate the requirements imposed on ProgIDs?


This MSDN article states that any ProgID must meet several formal requirements, length restriction included. However nothing is said about what happens if those are violated.

I found several places in our codebase where ProgIDs are longer than 39 characters, still everything seems to work allright for them, ProgIDFromCLSID() and CLSIDFromProgID() included.

Since violating those requirements is quite easy it would be very interesting to know what are the real possible consequences of such violations?


Solution

  • I guess what you get is undefined behavior. This can range from normal functioning to crashes, kittens being eaten, firstborns sacrificed, &c.

    More to the point, some requirements probably tell you a few things:

    • No more than 39 characters: Other software might use a fixed-size buffer of 40 chars to store a ProgID. They would therefore only have the first 39 and might not find your ProgID if it's longer.
    • Not start with a digit; contain no punctuation except periods: Again, this is a contract. Software may rely on this to verify ProgIDs it gets from somewhere that they are really ProgIDs and not something entirely different, for example.

    Windows might not bite you immediately but other things might.