Retrieving Path of the Program Associated with a File Type
-
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.
-
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.
As I remember the solution is using the function AssocQueryString. Unfortunately I have no source code here for an example. Jens
-
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.
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)
-
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.
-
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)
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.
-
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.
Sounds like you need the (updated) Platform SDK.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)