Note that on Windows/Linux at least, the user can install Anki in any folder they want. The above paths are the default paths. If you want the foolproof way, for Windows you probably have to poke around the registry to get the actual installation path (See anki.template.nsi), or you can just ask the user for the path if the default path didn’t work.
My suggestion would be - don’t do this. It will complicate unnecessarily things in your code and won’t give you or the user any significant benefits.
Just check the connection to anki and abort if it fails and give the user a notification that anki isn’t running.