COM without registration

January 6, 2008

25 comments

Those still using COM know that COM components must be registered in the Windows Registry to be workable. Sometimes this may not be acceptable. Sometimes you might want to run an application that may be using many COM DLLs, but don’t want or can’t (because of some policies) to register the components. Sometimes you want to run an application on some client’s machine without any setup. Can this be done? Off the bat, that seems impossible. But there is actually a way.

What I’ve done in a project (it was done a few years back) was this: when the main executable runs, it registers itself as a COM surrogate using ::CoRegisterSurrogate. After that it walks a list of all CLSIDs that are expected, loads the corresponsing DLL using the usual ::LoadLibrary and calls ::CoRegisterClassObject with a generic class factory and the REGCLS_SURROGATE flag. this makes the generic class factory (a simple class implementing IClassFactory) the universal creator.

Now, every time some code (in the EXE or in another DLL!) calls the usual ::CoCreateInstance (or CComPtr<> equivalents, or even a VB DLL calling CreateObject or New), the generic class factory returns the correct instance based on the requested CLSID.

I have used this method successfully for my company’s purpose – send demo CDs that require no installation and no registration.

If anyone is interested in the actual code, let me know and I’ll post it.

Like Don Box said: “COM is Love!” , but (I add) “sometimes a surrogate is needed”

 

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

25 comments

  1. golubFebruary 14, 2008 ב 12:20

    Hi Pavel,
    We have the same task. Could you please send me code example on kggol@yahoo.com

    Konstantin

    Reply
  2. pavelyFebruary 24, 2008 ב 22:05

    Hi Konstantin,

    Sorry for the long delay. I’m posting code sample now.

    Reply
  3. Sasha GoldshteinApril 30, 2008 ב 15:14

    Pavel,

    Windows XP features registration-free COM using manifests. You no longer need to do all the elaborate work manually.

    http://msdn.microsoft.com/en-us/magazine/cc188708.aspx

    Sasha

    Reply
  4. PavelApril 30, 2008 ב 17:38

    You are correct. But my method works on any Windows version (including Windows 98). This was a requirement at the time.

    Reply
  5. EvgenAugust 3, 2008 ב 02:05

    Could you please send me code example on xxevgenixx AT gmail DOT com

    Thank you

    Reply
  6. ValerySeptember 17, 2008 ב 00:40

    Hi Pavel,
    could you, please, send me code example to valeryg AT land TOCHKA ru
    Spasibo!

    Reply
  7. SandAugust 26, 2010 ב 10:08

    Hi Pavel:

    could you please post your code example to sand.fj.wen AT gmail DOT com ,

    Thanks so much!

    Reply
  8. RobertJanuary 14, 2011 ב 12:35

    Hi Pavel,

    could you please send me your code example to
    “robert DOT neumann AT gmx DOT de”? Its exactly what I have been looking for. Incredible that such a natural task is not easily possible with COM otherwise.

    Best regards!
    Robert.

    Reply
  9. Paul PredkiewiczJanuary 20, 2011 ב 10:15

    Hello Pavel,
    i have read this blogpost with great interest and i have a similar problem.
    I tried to avoid it by using a manifest, but for some reason this doesn’t work. Could you send me a code example how to implement this.

    Reply
  10. Paul PredkiewiczJanuary 20, 2011 ב 10:41

    Sorry, i forgot to add my email address. It’s ppredkiewicz at gruen dot net

    Reply
  11. JerryFebruary 10, 2011 ב 00:50

    Hi Pavel,

    could you please send me your code example to “jerrymats AT gmail DOT com”?

    Thanks,

    Jerry

    Reply
  12. Zuzu CorneliuJune 2, 2011 ב 23:55

    Hello Pavel,
    Can you also send the sample code to email address corneliuzuzu@yahoo.com or zuzucorneliu9@gmail.com?
    I need this urgently and you would help me very much by doing this favor for me.
    Thanks a lot in advance, Zozel

    Reply
  13. Zuzu CorneliuJune 3, 2011 ב 12:04

    Hello Pavel,
    Here I am again, waiting eagerly to get an answer from you.
    I really need to know if you can provide me with the sample code.
    I need to do what you succeeded in doing and I only have 2 more days besides this one.
    Please let me know if you still have the code, or, if not, if you can guide me trough the steps you took to achieve your result.

    I understand the part with CoRegisterSurrogate function, but between it and the LoadLibrary function things get kinda fuzzy. What do you mean by “After that it walks a list of all CLSIDs” – how does the executable “walk” these CLSIDs?

    Also – “and calls ::CoRegisterClassObject with a generic class factory and the REGCLS_SURROGATE flag. this makes the generic class factory (a simple class implementing IClassFactory) the universal creator.” – I need a bit of guidance here too.

    Thanks a lot in advance, and looking forward to talk to you.
    Thanks, Zozel

    Reply
  14. Markus SchmidtJuly 13, 2011 ב 14:00

    Hi Pavel,
    could you pls send me a code sample (to MarkusSchmidt1965 AT gmx DOT de).
    I want to test an alternative to Microsofts manifest-based way.
    Thank you in advance!

    Markus

    Reply
  15. SimonAugust 28, 2011 ב 13:16

    Hi Pavel:

    could you please post your code example to “s.verduci82 AT gmail DOT com” ?

    Thanks,
    Simon.

    Reply
  16. Matt SSeptember 5, 2011 ב 12:00

    Always wanted to say that whilst I worked woth Israel attar at Morse Property Consultants Ltd, he was a a controlling bully and not very good at his job.

    Reply
  17. Greg BOctober 3, 2011 ב 21:53

    Can you just post the code to the site instead of many emails?

    Reply
  18. Hola-October 9, 2011 ב 22:43

    hi.
    Dark energy, science’s biggest mystery
    http://soflobro.com

    Reply
  19. pepperJanuary 27, 2012 ב 19:07

    just a try

    Reply
  20. 501 thunderboltOctober 3, 2012 ב 18:27

    hi,
    I’m 501thunderbolt and would like if you guys could give a peep at my youtube video..thanks 501TB

    Reply
  21. PavelOctober 24, 2012 ב 15:31

    Hello, Pavel! If you still have example could you send it to me criativ@rambler.ru. thanks

    Reply
  22. bubuuDecember 5, 2012 ב 06:05

    Please check it i will be wery pleased, and if its not hard for you you can register and dont even use it well you can use it if you like, it takes just 1 minute :) thank you wery much :)

    Reply
  23. bobAugust 28, 2013 ב 01:54

    Hello Pavel,

    ich have currently the same problem. if you still have the code sample, please send it to bob84@gmx.de.
    Thank you a lot in advance.

    Yours
    Bob

    Reply