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. Retrieving Path of the Program Associated with a File Type

Retrieving Path of the Program Associated with a File Type

Scheduled Pinned Locked Moved C / C++ / MFC
helplinux
6 Posts 4 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.
  • A Offline
    A Offline
    Abin
    wrote on last edited by
    #1

    I got stuck on a project where it is needed to tell the path name of the program(if any) that is associated with a particular file type, i.e. I should be able to get "c:\\windows\\system32\\notepad.exe" from ".txt". I checked in HKEY_CLASS_ROOT but not every entry there has a "shell\\program" key so I think there must be other ways to retrieve the associated program... Thanks for your help.

    J D A 3 Replies Last reply
    0
    • A Abin

      I got stuck on a project where it is needed to tell the path name of the program(if any) that is associated with a particular file type, i.e. I should be able to get "c:\\windows\\system32\\notepad.exe" from ".txt". I checked in HKEY_CLASS_ROOT but not every entry there has a "shell\\program" key so I think there must be other ways to retrieve the associated program... Thanks for your help.

      J Offline
      J Offline
      Jens Doose
      wrote on last edited by
      #2

      As I remember the solution is using the function AssocQueryString. Unfortunately I have no source code here for an example. Jens

      1 Reply Last reply
      0
      • A Abin

        I got stuck on a project where it is needed to tell the path name of the program(if any) that is associated with a particular file type, i.e. I should be able to get "c:\\windows\\system32\\notepad.exe" from ".txt". I checked in HKEY_CLASS_ROOT but not every entry there has a "shell\\program" key so I think there must be other ways to retrieve the associated program... Thanks for your help.

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

        Try this:

        char szAssocProgram[MAX_PATH];
        DWORD dwSize = MAX_PATH;
        HRESULT hr = AssocQueryString(0, ASSOCSTR_EXECUTABLE , ".txt", NULL, szAssocProgram, &dwSize);


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        R 1 Reply Last reply
        0
        • A Abin

          I got stuck on a project where it is needed to tell the path name of the program(if any) that is associated with a particular file type, i.e. I should be able to get "c:\\windows\\system32\\notepad.exe" from ".txt". I checked in HKEY_CLASS_ROOT but not every entry there has a "shell\\program" key so I think there must be other ways to retrieve the associated program... Thanks for your help.

          A Offline
          A Offline
          Abin
          wrote on last edited by
          #4

          Thanks for the replies, I really appreciated. geeze, CP is such a good place to hang around...

          1 Reply Last reply
          0
          • D David Crow

            Try this:

            char szAssocProgram[MAX_PATH];
            DWORD dwSize = MAX_PATH;
            HRESULT hr = AssocQueryString(0, ASSOCSTR_EXECUTABLE , ".txt", NULL, szAssocProgram, &dwSize);


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            R Offline
            R Offline
            Rick York
            wrote on last edited by
            #5

            I see this in the on-line docs and it says it is available for 2000 and 98 but my version of shlwapi.h in MSVC v6.0 SP6 does not have it. Which version of shlwapi.h does have it ? __________________________________________ a two cent stamp short of going postal.

            D 1 Reply Last reply
            0
            • R Rick York

              I see this in the on-line docs and it says it is available for 2000 and 98 but my version of shlwapi.h in MSVC v6.0 SP6 does not have it. Which version of shlwapi.h does have it ? __________________________________________ a two cent stamp short of going postal.

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

              Sounds like you need the (updated) Platform SDK.


              "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

              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