Passing 'open' to ShellExecute does not 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 open using wordpad.

Word 2010 is installed correctly, and double-clicking in the text file from the explorer opens the word correctly, moreover, the document is displayed with the correct icon in the explorer. Please note that all other files work fine (e.g. xls, xlsx, pdf, ...)

Does anyone know why? I checekd and โ€œuse this application to open filesโ€, it is checked.

In the code I check for an error and I know that the error message

SE_ERR_ASSOCINCOMPLETE or SE_ERR_NOASSOC

(because in both cases I show the error "no application is associated with the file type", so I donโ€™t know which of the errors is, I shuold debug the client part to see it, but I donโ€™t think it is so important in this case )

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

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

Note: it seems to me that there is a problem in the Windows registry for this machine, it is almost a new Windows 7 machine.

NOTE for those who vote to close this question as Off Topic: this is actually a question in WinAPI: why does this api not work as expected when it does from explorer? So this is not off topic, especially winapi is in the tags.

+6
source share
1 answer

This is just an assumption, but I suspect Explorer is using NULL where you have "open". This can cause subtly different behavior if nothing happens in user registered file associations. For example, if there is a default verb other than "open".

+5
source

Source: https://habr.com/ru/post/890239/


All Articles