问题
So many programs feature a list of possible extensions and protocols under the "Default Programs" control panel applet. "Set Default PRograms", more precisely. (Vista & 7)
I wish to add my programs in that list and set some extensions that it can handle.
One more thing. My program supports addons for opening more files, so that list should be dynamic (I can add more extensions or even protocols at any time)
By the way, yes, I know, this is not exactly a programming question. It'd be my humble guess that it's a registry question. So UAC will not be an issue!
回答1:
The registry keys required to register your application with the Default Programs UI is documented on MSDN (Part of the Shell Developer's Guide)
回答2:
OK so after hard work and a half-an-hour long registry search, I have found out that I have to register my applications capabilities and then register my application.
For others, analyze the values in this key:
HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications
回答3:
Here is the one i use to associate mainly video files with Media Player Classic (Gabest) in windows 7:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Media\Media Player Classic (Gabest)]
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Media\Media Player Classic (Gabest)\Capabilities]
"ApplicationDescription"="One of the most powerful, configurable multimedia players for Windows operating system, made by a Hungarian developer known as Gabest."
"ApplicationIcon"="C:\\Program Files\\mplayerc.exe,0"
"ApplicationName"="Media Player Classic (Gabest)"
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Media\Media Player Classic (Gabest)\Capabilities\FileAssociations]
".avi"="mpc.avi"
".mpg"="mpc.mpg"
".mpeg"="mpc.mpeg"
".mpe"="mpc.mpe"
".m1v"="mpc.m1v"
".m2v"="mpc.m2v"
".mpv2"="mpc.mpv2"
".mp2v"="mpc.mp2v"
".pva"="mpc.pva"
".evo"="mpc.evo"
".m2p"="mpc.m2p"
".ts"="mpc.ts"
".tp"="mpc.tp"
".trp"="mpc.trp"
".m2t"="mpc.m2t"
".m2ts"="mpc.m2ts"
".mts"="mpc.mts"
".rec"="mpc.rec"
".vob"="mpc.vob"
".ifo"="mpc.ifo"
".mkv"="mpc.mkv"
".webm"="mpc.webm"
".mp4"="mpc.mp4"
".m4v"="mpc.m4v"
".mp4v"="mpc.mp4v"
".mpv4"="mpc.mpv4"
".hdmov"="mpc.hdmov"
".mov"="mpc.mov"
".3gp"="mpc.3gp"
".3gpp"="mpc.3gpp"
".3ga"="mpc.3ga"
".3g2"="mpc.3g2"
".3gp2"="mpc.3gp2"
".flv"="mpc.flv"
".f4v"="mpc.f4v"
".ogm"="mpc.ogm"
".ogv"="mpc.ogv"
".rm"="mpc.rm"
".ram"="mpc.ram"
".rmm"="mpc.rmm"
".rt"="mpc.rt"
".rp"="mpc.rp"
".smi"="mpc.smi"
".smil"="mpc.smil"
".wmv"="mpc.wmv"
".wmp"="mpc.wmp"
".wm"="mpc.wm"
".asf"="mpc.asf"
".smk"="mpc.smk"
".bik"="mpc.bik"
".fli"="mpc.fli"
".flc"="mpc.flc"
".flic"="mpc.flic"
".dsm"="mpc.dsm"
".dsv"="mpc.dsv"
".dsa"="mpc.dsa"
".dss"="mpc.dss"
".ivf"="mpc.ivf"
".d2v"="mpc.d2v"
".swf"="mpc.swf"
".divx"="mpc.divx"
".rmvb"="mpc.rmvb"
".amv"="mpc.amv"
".dts"="mpc.dts"
".aif"="mpc.aif"
".aifc"="mpc.aifc"
".aiff"="mpc.aiff"
".alac"="mpc.alac"
".amr"="mpc.amr"
".apl"="mpc.apl"
".au"="mpc.au"
".snd"="mpc.snd"
".m4r"="mpc.m4r"
".mka"="mpc.mka"
".mpa"="mpc.mpa"
".m1a"="mpc.m1a"
".m2a"="mpc.m2a"
".ra"="mpc.ra"
".aob"="mpc.aob"
".mlp"="mpc.mlp"
".wvx"="mpc.wvx"
".wmx"="mpc.wmx"
".mpcpl"="mpc.mpcpl"
".mpls"="mpc.mpls"
".bdmv"="mpc.bdmv"
[HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications]
"Media Player Classic (Gabest)"="SOFTWARE\\Clients\\Media\\Media Player Classic (Gabest)\\Capabilities"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\mplayerc.exe\SupportedTypes]
".avi"=""
".mpg"=""
".mpeg"=""
".mpe"=""
".m1v"=""
".m2v"=""
".mpv2"=""
".mp2v"=""
".pva"=""
".evo"=""
".m2p"=""
".ts"=""
".tp"=""
".trp"=""
".m2t"=""
".m2ts"=""
".mts"=""
".rec"=""
".vob"=""
".ifo"=""
".mkv"=""
".webm"=""
".mp4"=""
".m4v"=""
".mp4v"=""
".mpv4"=""
".hdmov"=""
".mov"=""
".3gp"=""
".3gpp"=""
".3ga"=""
".3g2"=""
".3gp2"=""
".flv"=""
".f4v"=""
".ogm"=""
".ogv"=""
".rm"=""
".ram"=""
".rmm"=""
".rt"=""
".rp"=""
".smi"=""
".smil"=""
".wmv"=""
".wmp"=""
".wm"=""
".asf"=""
".smk"=""
".bik"=""
".fli"=""
".flc"=""
".flic"=""
".dsm"=""
".dsv"=""
".dsa"=""
".dss"=""
".ivf"=""
".d2v"=""
".swf"=""
".divx"=""
".rmvb"=""
".amv"=""
".ac3"=""
".dts"=""
".aif"=""
".aifc"=""
".aiff"=""
".alac"=""
".amr"=""
".ape"=""
".apl"=""
".au"=""
".snd"=""
".cda"=""
".flac"=""
".m4a"=""
".m4b"=""
".m4r"=""
".aac"=""
".mid"=""
".midi"=""
".rmi"=""
".mka"=""
".mp3"=""
".mpa"=""
".mp2"=""
".m1a"=""
".m2a"=""
".mpc"=""
".ofr"=""
".ofs"=""
".ogg"=""
".oga"=""
".opus"=""
".ra"=""
".tak"=""
".tta"=""
".wav"=""
".wma"=""
".wv"=""
".aob"=""
".mlp"=""
".asx"=""
".m3u"=""
".m3u8"=""
".pls"=""
".wvx"=""
".wax"=""
".wmx"=""
".mpcpl"=""
".mpls"=""
".bdmv"=""
[HKEY_CLASSES_ROOT\mpc.3g2]
@="3G2"
"EditFlags"=dword:00000000
"FriendlyTypeName"="3G2"
[HKEY_CLASSES_ROOT\mpc.3g2\CurVer]
@="mpc.3g2"
[HKEY_CLASSES_ROOT\mpc.3g2\shell]
@="open"
[HKEY_CLASSES_ROOT\mpc.3g2\shell\open]
[HKEY_CLASSES_ROOT\mpc.3g2\shell\open\command]
@="\"C:\\Program Files\\mplayerc.exe\" \"%1\""
[HKEY_CLASSES_ROOT\mpc.3ga]
@="3GA"
"EditFlags"=dword:00000000
"FriendlyTypeName"="3GA"
[HKEY_CLASSES_ROOT\mpc.3ga\CurVer]
@="mpc.3ga"
[HKEY_CLASSES_ROOT\mpc.3ga\shell]
@="open"
[HKEY_CLASSES_ROOT\mpc.3ga\shell\open]
[HKEY_CLASSES_ROOT\mpc.3ga\shell\open\command]
@="\"C:\\Program Files\\mplayerc.exe\" \"%1\""
[HKEY_CLASSES_ROOT\mpc.3gp]
@="3GP"
"EditFlags"=dword:00000000
"FriendlyTypeName"="3GP"
[HKEY_CLASSES_ROOT\mpc.3gp\CurVer]
@="mpc.3gp"
[HKEY_CLASSES_ROOT\mpc.3gp\shell]
@="open"
[HKEY_CLASSES_ROOT\mpc.3gp\shell\open]
[HKEY_CLASSES_ROOT\mpc.3gp\shell\open\command]
@="\"C:\\Program Files\\mplayerc.exe\" \"%1\""
[HKEY_CLASSES_ROOT\mpc.3gp2]
@="3GP2"
"EditFlags"=dword:00000000
"FriendlyTypeName"="3GP2"
[HKEY_CLASSES_ROOT\mpc.3gp2\CurVer]
@="mpc.3gp2"
[HKEY_CLASSES_ROOT\mpc.3gp2\shell]
@="open"
[HKEY_CLASSES_ROOT\mpc.3gp2\shell\open]
[HKEY_CLASSES_ROOT\mpc.3gp2\shell\open\command]
@="\"C:\\Program Files\\mplayerc.exe\" \"%1\""
[HKEY_CLASSES_ROOT\mpc.3gpp]
@="3GPP"
"EditFlags"=dword:00000000
"FriendlyTypeName"="3GPP"
[HKEY_CLASSES_ROOT\mpc.3gpp\CurVer]
@="mpc.3gpp"
[HKEY_CLASSES_ROOT\mpc.3gpp\shell]
@="open"
[HKEY_CLASSES_ROOT\mpc.3gpp\shell\open]
[HKEY_CLASSES_ROOT\mpc.3gpp\shell\open\command]
@="\"C:\\Program Files\\mplayerc.exe\" \"%1\""
...................cont'd............
Full version here: http://pastebin.com/BinZdHVU
回答4:
Your'e going to do this as part of the installation process for your application. If you're using WIX, you can configure following the answer in this question:
If you do want to do this through code, check out the following article. It is written using VB.Net, but the code is rather simple and can be easily translated to C#.
来源:https://stackoverflow.com/questions/5542354/how-do-i-add-my-application-in-the-default-programs-list-of-windows-vista-7