Default application on Windows

Issue #569 closed
kae meanee created an issue

I want to set this as the default calculator application in Windows, and for that to happen the application must request to be used for the "url:calculator" protocol. For some reason (this is a Windows issue at least), it doesn't recognize it as a valid program when trying to set default applications by protocol.

Another alternative would be launching it somehow with a hotkey, or when the numlock is turned on.

Comments (12)

  1. Pol Welter

    I've never heard of this url:calculator thing. What version of Windows are you on? Can you provide a link to a description of what you did?

    AFAIK the default calculator app is defined somewhere in the registry. On WIN7, it is in

    HKEY_LOCAL_MACHINE/software/microsoft/windows/currentversion/explorer/appkey/18/ShellExecute.

  2. kae meanee reporter

    url:calculator is found in HKCR\calculator, and you'd specify the application to run as a string under HKCR\calculator\shell\open\command with the path to the executable as the value. It is also found somewhere in HKU\{}\SOFTWARE\Classes.

    I'm on Windows 10, and I found nothing in the location you mentioned.

  3. Pol Welter

    Interesting. MS must have moved things around in one of their newer OSes. Makes sense, the old path of the key was fairly obscure.

    Anyway, I do not have a machine with Windows 10 around, so I cannot look into this. Sorry!

    If everything else fails, just replace calc.exe with SpeedCrunch :P

  4. Tey'

    From what I understand, registering SpeedCrunch in the HKCR\calculator key is like defining a new network protocol scheme to be used in URL (using calculator:// in URL the same way as http://). But I'm not aware of any uses of the calculator protocol in Windows.

    Are you sure this is not something specific to your installation kae? I found nothing about url:calculator or HKCR\calculator using Google. Do you have any references about that?

    We could add this registration in the Windows installer, but only if it is a Windows "standard".

    BTW, the key Pol gave is for registering SpeedCrunch as the default calculator application for keyboards that have a specific button to launch the Windows calculator.

  5. kae meanee reporter

    I honestly don't know, I searched around for changing the default calculator app in Win10 and that's what I found.
    But if you're certain on where the registry hold this information, why not make it an option in the program to set it as default?

  6. Tey'

    I've checked on a Windows 10 box, and the HKCR\calculator does not exist by default.

    As for giving the possibility to set SC as the default calculator directly from the application, this is not wanted because SC is platform-agnostic, so we try to avoid putting specific platform logic in it (Qt does most of the cross-platform job). That's why I suggested to add such an option in the installer instead, because the installer is different for each platform.

  7. Felix Krull

    I did some experimentation. All my Windows 10 systems have a calculator: URL scheme (in HKCR\calculator); it might've only appeared after some time. The only app that's registered for that protocol is the default Calculator app. I assume the protocol is for WinRT apps to be able to launch a calculator, but I couldn't find any documentation on it.

    I managed to register SpeedCrunch for that protocol (via https://msdn.microsoft.com/en-us/library/windows/desktop/cc144154%28v=vs.85%29.aspx). Notably, now that the classic calculator is gone in 10, calc.exe simply invokes the default handler for the calculator: protocol, so I got calc.exe to open SpeedCrunch. I have a commit, but it's sitting on top of my CPack stuff, so it'll have to wait: https://bitbucket.org/fk/speedcrunch/commits/bd51c0f75919c21f4d1d4277e6de08a743088179

    (Weirdly, I couldn't make SpeedCrunch show up in the "Set Default Programs" control panel; that seems to be some problem with the executable's version info resource, but I couldn't figure it out.)

  8. Tey'

    Indeed, I've just installed a fresh Win10 version, and the HKCR\calculator key was present. It does not seem to be a real protocol as the default calculator app ignores whatever is present after the calculator: string.

    As for the "Set Default Programs" panel, try adding the following commands in the install script, and SC should now be listed:

    WriteRegStr SHCTX 'Software\\\\Classes\\\\SpeedCrunch.Url.calculator\\\\Application' 'AppUserModelId' 'SpeedCrunch'
    WriteRegStr SHCTX 'Software\\\\Classes\\\\SpeedCrunch.Url.calculator\\\\Application' 'ApplicationIcon' '\\\"$INSTDIR\\\\${BINDIR}\\\\${PROGNAME}.exe,0\\\"'
    WriteRegStr SHCTX 'Software\\\\Classes\\\\SpeedCrunch.Url.calculator\\\\Application' 'ApplicationName' 'SpeedCrunch'
    WriteRegStr SHCTX 'Software\\\\Classes\\\\SpeedCrunch.Url.calculator\\\\Application' 'ApplicationDescription' 'A high-precision scientific calculator'
    WriteRegStr SHCTX 'Software\\\\Classes\\\\SpeedCrunch.Url.calculator\\\\Application' 'ApplicationCompany' 'SpeedCrunch'
    

    I've tested it works with REG files only, so maybe it does not work correctly with the installer (I can't test). Also, the SC icon does not show in that panel until SC has been selected as the default handler (adding the SOFTWARE\Classes\SpeedCrunch.Url.calculator\DefaultIcon key does not help).

  9. Felix Krull

    Huh. I'll check on my VM park later, but just adding the ApplicationCompany key made SpeedCrunch show up in the Default Programs list on two Windows 10 systems, icon, name, description and all. I suspect it has something to do with this bit of wisdom hidden in the comments on the MSDN page I linked:

    Windows 8 and onwards requires "Company name" to be present in the version information resource block for the associated executable.

  10. Log in to comment