Programmatically detect if Windows Media Player is installed

旧街凉风 提交于 2019-12-11 05:38:38

问题


Anybody have any advice on how to programmatically detect if Windows Media Player is installed?

I know about the registry setting look up, but don't trust it since it's more than a little misleading (uninstalled may not remove it). And I've considered just launching a video, but an error could be caused by something other than Media Player not being installed, so it's not conclusive either.

Ideally, I'd prefer a solution which could be used from both my C++ application AND my NSIS installer. But my the C++ app is the most important, I'm willing to live with the registry hack in the installer.


回答1:


Look at the IsInstalled value under key HKLM\Software\Microsoft\Active Setup\Installed Components\{22d6f312-b0f6-11d0-94ab-0080c74c7e95}. It is 1 if installed, 0 otherwise.

See Detecting Windows Media Player from an Application.




回答2:


(You don't say whether you're checking for an embeddable (i.e. OCX) player to embed in your app or the EXE to launch extenally from your app.)

How about checking the HRESULT on CoCreateInstance against CLSID {22d6f312-b0f6-11d0-94ab-0080c74c7e95} / ProgID "MediaPlayer.MediaPlayer.1" in your app? (CLSIDs from http://technet.microsoft.com/en-us/library/bb676121.aspx)

In your installer just check for HKEY_CLASSES_ROOT\CLSID{22D6F312-B0F6-11D0-94AB-0080C74C7E95}, and perhaps also that the path at the InprocServer32 subkey exists.




回答3:


If the uninstall fails to remove both the EXE and the registry entry then I highly doubt it uninstalled anything...

So, I would suggest you check the registry under HKLM\Software\Microsoft\MediaPlayer\ and if it exists, grab the value of the Installation Directory or Installation DirectoryLFN (default is %ProgramFiles%\Windows Media Player) and check that wmplayer.exe exists within that directory. If it does, then you will know that WMP is installed.



来源:https://stackoverflow.com/questions/4035494/programmatically-detect-if-windows-media-player-is-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!