26. Windows API shell programming (2)

Source: Internet
Author: User

Ii. Document assistance(File Associations)

File AssociationsYou can specifyShellThe methods used to display and process objects of a specific file type include the following:

◇ Which application is used to double-click a file?ProgramIt should be used to open this file;

◇ File icons;

◇ InExplorerThe file type displayed during browsing;

◇ Commands (menu items) displayed in the context menu of the file );

◇ Some user interface details, such as the prompt message popped up when the mouse pointer stays on the icon(Infotip).

AndFile AssociationsAn important concept is "file type". Each file type corresponds to a specific file extension. To enableShell (Explorer.EXE)To correctly identify the file type, you must register it in the registry. Only the file type that is correctly registered in the RegistryShellTo know how to select the file icon and how to specify the application required to open the file when double-clicking the file.

1, File type related registry key value

1) File type

Files with the same file extension belong to the same file type. If you need Shell To identify this type of file, you must register it in the registry. Registering a file includes two types: Hkey_classes_root Set the extension sub-key, and set the default value to Progid (programmatic identifiers , Programmable identifier ) 2. Hkey_classes_root Key Value Creation Progid Sub-keys, and set related properties.

2) Extension key

Hkey_classes_rootExcept for the default key valueProgidYou can also set other key values or subkeys. IncludingPerceivedtypeAndContent typeKey Value andPenwithprogidsAndOpenwithlistSub-Keys.

OpenwithlistAndOpenwithprogidsThe subkeys set the "open mode" list and the "open mode"-"Select Program" dialog box.

3) Programmable identifier

progid multiple seed keys: defaulticon , curver , shell , shellex , it also has multiple key values infotip , friendlytypename .

ProgidSpecifies the description of the file type;InfotipThe key value specifies the prompt that appears when you move the mouse pointer to a file of this type.

DefaulticonThe sub-key specifies the default icon for this file type.CurverIndicates the current version.

ShellSub-keys include several command handlers(Handler), There are some defaultHandler(Open,PlayYou can also register customHandler.

Shellex Including several Shell Extended Handler , Used to add new right-click menu items, file drag menu, icon, attribute dialog box, and prompt dialog box, including Context Menu Handler , Data Handler , Drop Handler , Icon Handler , Property sheet Handler , Infotip Handler , Copy hook Handler .

2Specify the default program for the file

You can use the registry to specify the Default Programs for files of a specific file type. After the program is opened by defaultExploerer.exeDouble-click or right-click to open the file.

As follows:RegExampleCode:

. Reg

 Regedit4

[Hkey_classes_root \. Win]
@ = " Winfile "
[Hkey_classes_root \ winfile]
@ = " File Type example "

[Hkey_classes_root \ winfile \ defaulticon]
@ = " Shell32.dll,-152. "
[Hkey_classes_root \ winfile \ shell \ open \ command]
@ = " Notepad. EXE % 1 "

Use the preceding method. You canShellRegister a new file type. However, after you directly modify the registry key value,Assumer.exeIt is not immediately associated with the new settings. So you need to log out and log on again to restartAssumer.exe.

ShchangenoworkflowFunctions can enableAssumer.exeReload registry settings. You do not have to log on again. The newly registered file type will take effect. Use the following parametersShchangenoworkflow:

Shchangenoworkflow

 #include     Windows. h  >  
# include shlobj. h >
int winapi winmain (
hinstance,
hinstance hprevinstance,
lpstr lpcmdline,
int ncmdshow
)
{< br> winexec ( " Regedit win. reg " , ncmdshow );
shchangenovel (shcn_assocchanged, shcnf_idlist, null, null);
}

Reference

[1]ProficientWindows APIFunctions, interfaces, and programming instances

[2] http://msdn.microsoft.com/en-us/library/bb773177%28VS.85%29.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.