Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing 'open' to ShellExecute doesn't open a word file on a specific machine

I use ShellExecute to open files. On a single machine among 2000+ users I cannot open doc files. docx are opened with Wordpad.

Word 2010 is correctly installed and from explorer double cliicking on a word file opens word correctly, moreover the doc is showing with the correct icon in explorer. Note that all the other files work ok (like xls, xlsx, pdf, ...)

Does anyone know why? I checekd and "use this application to open files" it is checked.

In code I check the error and I know that the error message is

SE_ERR_ASSOCINCOMPLETE or SE_ERR_NOASSOC

(becuase in both cases I show an error "no appliaction is associated with the type of file", so i don't know which of the errors is there, I shuold debug at customer end to see it, but I don't think it is so important in this case).

Has anyone an idea? This is what I use to open the file:

ShellExecute(0, 'open', PWideChar(MyFilePath), '', '', SW_SHOWNORMAL);

Note: it looks to me some like problem is there in windows registry for this machine, it is a almost fresh windows 7 machine.

NOTE for who is voting for closing this question as Off Topic: it is in fact a question on WinAPI: why this api doesn't work as expected when from explorer it does? So this is not off topic, expecially winapi is in tags.

like image 866
LaBracca Avatar asked Jun 10 '11 16:06

LaBracca


1 Answers

This is just a guess, but I suspect Explorer is using NULL where you have "open". This can trigger subtly different behavior if there's anything amiss in the user's registered file associations. For example, if there's a default verb other than "open".

like image 140
Adrian McCarthy Avatar answered Nov 06 '22 17:11

Adrian McCarthy