Windows 7 Library: C # Quick Reference

Source: Internet
Author: User

If you do not know the concept of Windows 7 library, read this article first: Windows 7 new function: Library)

The following is a quick reference for some common Windows 7 library functions, using the Windows API code pack.

This articleArticleInCodeMembers from the Aaron and SELA teams.

Each Windows 7 library is represented by an XML file with the extension. Library-MS.

Common library files are usually stored in: C: \ Users \ <username> \ appdata \ roaming \ Microsoft \ Windows \ libraries \.

For example, you can use the image library as follows:

1 Libraryname = Pictures
2 Locationpath = C: \ Users \ < Username > \ Appdata \ roaming \ Microsoft \ Windows \ libraries \

Note: You can create a library file anywhere, not necessarily in the preceding folder.

Function:

Create a new database:

1 Shelllibrary =  
2 New Shelllibrary (libraryname, locationpath, overwriteexisting );

Add a folder to an existing Library:

1 Using (Shelllibrary =
2 Shelllibrary. Load (libraryname, folderpath, isreadonly ))
3 {
4 Shelllibrary. Add (foldertoadd );
5 }

Delete a folder from the Library:

1 Using (Shelllibrary =
2 Shelllibrary. Load (libraryname, folderpath, isreadonly ))
3 {
4 Shelllibrary. Remove (foldertoremove );
5 }

Enumeration library Folder:

1 Using (Shelllibrary =  
2 Shelllibrary. Load (libraryname, folderpath, isreadonly ))
3 {
4 Foreach (Shellfilesystemfolder folder In Shelllibrary)
5 {
6 Debug. writeline (Folder. Path );
7 }
8 }

Change the default storage location:

1 Using (Shelllibrary =  
2 Shelllibrary. Load (libraryname, folderpath, isreadonly ))
3 {
4 Shelllibrary. defaultsavefolder = Newsavelocation;
5 }

Change library icon:

1 Using (Shelllibrary =  
2 Shelllibrary. Load (libraryname, folderpath, isreadonly ))
3 {
4 Shelllibrary. iconresourceid =   New Iconreference (modulename, resourceid );
5 }

Lock library Navigation Pane:

1 Using (Shelllibrary =  
2 Shelllibrary. Load (libraryname, folderpath, isreadonly ))
3 {
4 Shelllibrary. ispinnedtonavigationpane =   True ;
5 }

Set the library type:

1 Using (Shelllibrary =  
2 Shelllibrary. Load (libraryname, folderpath, isreadonly ))
3 {
4 Shelllibrary. librarytype = Librarytype;
5
6 // Librarytype can be:
7 // Libraryfoldertype. Generic
8 // Libraryfoldertype. Documents
9 // Libraryfoldertype. Music
10 // Libraryfoldertype. Pictures
11 // Libraryfoldertype. Videos
12 }

Open the library management interface:

1 Shelllibrary. showmanagelibraryui (
2 Libraryname, folderpath, hownerwnd, title, instruction, allownonindexablelocations );

Delete database:

1 String Fileextension =   " . Library-MS " ;
2
3 File. Delete (path. Combine (folderpath, libraryname + Fileextension ));

Notification of database changes:

1 String Fileextension =   " . Library-MS " ;
2
3 Filesystemwatcher librarywatcher =   New Filesystemwatcher (folderpath );
4 Librarywatcher. policyfilter = Policyfilters. lastwrite;
5 Librarywatcher. Filter = Libraryname + Fileextension;
6 Librarywatcher. includesubdirectories =   False ;
7
8 Librarywatcher. Changed + = (S, E) =>
9 {
10 // Cross thread call
11 This . Dispatcher. Invoke ( New Action (() =>
12 {
13 Using (Shelllibrary =  
14 Shelllibrary. Load (libraryname, folderpath, isreadonly ))
15 {
16 // Get changed information
17 ...
18 }
19 }));
20 };
21 Librarywatcher. enableraisingevents =   True ;

Original article: http://blogs.microsoft.co.il/blogs/arik/archive/2010/03/15/windows-7-libraries-c-quick-reference.aspx

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.