سؤال

I call standard ShellExecuteW call on Windows8.1 to open PPS (powerpoint slide) file.

This works just fine on Windows 7. On Windows 8.1. it reports "There is no program associated to open the file". Of course, the file association is set and if file is saved and run from Explorer (double clicked) it opens just fine. I also tried to change association and to associate another program and then associate back to PPS viewer, no improvement. It just doesn't work for W8.1 but the same call works on earlier Windows.

Can anyone give me a clue what might be wrong here?

The code used to open file is very simple and I see no errors with it:

HINSTANCE hinst = ShellExecuteW(NULL, L"open", L"C:\\path\\to\\file.pps", NULL, NULL, SW_SHOWNORMAL);

// Check if result is error
if ((int)hinst <= 32)
    {
    wchar_t buf[512] = { 0 };
    FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 512, NULL);

    MSGBOX(buf);
    }

I use free PPS viewer as found here: http://www.microsoft.com/en-us/download/details.aspx?id=13

I found something similar which points to that this could be a bug in Win8.1. Can anyone confirm this? Or reveal a workaround?

هل كانت مفيدة؟

المحلول

I found the solution myself.

The problem on W8.1 was that the verb open was not registered to the application so it used different default verb. So if the ShellExecute call is replaced with:

HINSTANCE hinst = ShellExecuteW(NULL, NULL, L"C:\\path\\to\\file.pps", NULL, NULL, SW_SHOWNORMAL);

Then the system looks for a default verb which may or may not be open (usually is), so by not using this verb explicitly it leaves this decision to the system.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top