Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Does windows XP use COM to determine file associations?

Does windows XP use COM to determine file associations?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionhtmlcom
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kinar
    wrote on last edited by
    #1

    I've got an app that uses a ShellExecute to launch the default web browser via ShellExecute(NULL, "open", "http://somewebsite.com", NULL, NULL, SW_SHOWNORMAL); On XP, sometimes it works and other times it doesn't resulting in an Error code 5 being returned from the ShellExecute (error code 5 = SE_ACCESS_DENIED) indicating that the OS refused to launch the default web browser. From the MSDN documentation for ShellExecute, I noticed the bit about if what you are launching uses COM, you will need to initialize COM in your app before calling ShellExecute. When I add the CoInitialize(NULL) at app startup (and the CoUninitialize at the close), it fixes the problem and the page launches every time. This is all great...but why does it work? the only thing I can come up with is that Windows uses COM to determine what app should open html files. Except that doesn't make sense as to why it sometimes works... What am I missing? Oh, and Vista/win7 works. This behavior is only seen on XP

    D 1 Reply Last reply
    0
    • K kinar

      I've got an app that uses a ShellExecute to launch the default web browser via ShellExecute(NULL, "open", "http://somewebsite.com", NULL, NULL, SW_SHOWNORMAL); On XP, sometimes it works and other times it doesn't resulting in an Error code 5 being returned from the ShellExecute (error code 5 = SE_ACCESS_DENIED) indicating that the OS refused to launch the default web browser. From the MSDN documentation for ShellExecute, I noticed the bit about if what you are launching uses COM, you will need to initialize COM in your app before calling ShellExecute. When I add the CoInitialize(NULL) at app startup (and the CoUninitialize at the close), it fixes the problem and the page launches every time. This is all great...but why does it work? the only thing I can come up with is that Windows uses COM to determine what app should open html files. Except that doesn't make sense as to why it sometimes works... What am I missing? Oh, and Vista/win7 works. This behavior is only seen on XP

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      kinar wrote:

      the only thing I can come up with is that Windows uses COM to determine what app should open html files.

      Last time I checked, it consulted the registry.

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      CPalliniC 1 Reply Last reply
      0
      • D David Crow

        kinar wrote:

        the only thing I can come up with is that Windows uses COM to determine what app should open html files.

        Last time I checked, it consulted the registry.

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        DavidCrow wrote:

        Last time I checked, it consulted the registry.

        Did you consult the registry to come up with such conclusion? :-D

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        In testa che avete, signor di Ceprano?

        D 1 Reply Last reply
        0
        • CPalliniC CPallini

          DavidCrow wrote:

          Last time I checked, it consulted the registry.

          Did you consult the registry to come up with such conclusion? :-D

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          No, I used an API.

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups