WEB开发网
开发学院软件开发C语言 Windows 7库(Library):C#快速参考 阅读

Windows 7库(Library):C#快速参考

 2010-09-30 22:43:14 来源:WEB开发网   
核心提示: 更改默认保存位置:1using(ShellLibraryshellLibrary=2ShellLibrary.Load(libraryName,folderPath,isReadOnly))3{4shellLibrary.DefaultSaveFolder=newSaveLocation;5}更

更改默认保存位置: 

1 using (ShellLibrary shellLibrary = 
2     ShellLibrary.Load(libraryName, folderPath, isReadOnly))
3 {
4     shellLibrary.DefaultSaveFolder = newSaveLocation;
5 }

更改库图标:

1 using (ShellLibrary shellLibrary = 
2     ShellLibrary.Load(libraryName, folderPath, isReadOnly))
3 {
4     shellLibrary.IconResourceId = new IconReference(moduleName, resourceId);
5 }

锁住库浏览导航窗格:

1 using (ShellLibrary shellLibrary = 
2     ShellLibrary.Load(libraryName, folderPath, isReadOnly))
3 {
4     shellLibrary.IsPinnedToNavigationPane = true;
5 }

设置库的类型:

 1 using (ShellLibrary 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 }

打开库管理界面:

1 ShellLibrary.ShowManageLibraryUI(
2     libraryName, folderPath, hOwnerWnd, title, instruction, allowNonIndexableLocations);

删除库:

1 string FileExtension = ".library-ms";
2 
3 File.Delete(Path.Combine(folderPath,libraryName + FileExtension));

获取库的更改通知:

 1 string FileExtension = ".library-ms";
 2 
 3 FileSystemWatcher libraryWatcher = new FileSystemWatcher(folderPath);
 4 libraryWatcher.NotifyFilter = NotifyFilters.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 shellLibrary = 
14                 ShellLibrary.Load(libraryName, folderPath, isReadOnly))
15             {
16                 // get changed information
17                 ...
18             }
19         }));
20 };
21 libraryWatcher.EnableRaisingEvents = true;

出处:http://zhuqil.cnblogs.com

上一页  1 2 

Tags:Windows Library 快速

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接