Microsoft Study Bible

September 25, 2009

Programming with libraries in Windows 7, VS2010??

Windows 7 has its share of highly visible user interface tweaks. After getting past the oohs and aahs of the spiffed-up taskbar, you’ll likely find the new look of good old Explorer the most dramatic difference. Click the Windows Explorer icon on the taskbar, or open Computer from the Start menu, and you’ll get a window that displays not only the standard expandable hard drive labels but also a new feature called Libraries. Before Windows 7 can be useful, you need to understand how it organizes your data with Libraries, the new features in Windows 7.

So, how to perform most of the management operations on a library?

As developers and programmers, how to explore the libraries in Windows7?

  In win7 OS, we can manually manage and create the libraries, and add and delete the folder. Howeverthe developers’  most concern is how to perform management operations in libraries and use libraries in applications .In order to use the libraries, Windows 7 provide the new IShellLibrary API to empower your applications to manipulate libraries.

  This can help ensure that applications remain in sync with user files and Windows since any change made to a library structure will be reflected in the application that is monitoring that library – giving us developers great power and great responsibility.

cfbc519f-ea08-41c8-b106-214cc9b894d2

On the above image ,the top layer is User Interface APIs ,which contains CFDNavigation bar Tree Controls, and so on. With User Interface APIs, we can call the new edition of CFD that support libraries to make the applications could support this new feature in libraries when our applications was opened or stored.

Here is a look at this feature in the application instance.

private void button1_Click(object sender, EventArgs e)
  
    {
  
        string strPath;
  
        // create the new edition of the common file dialog
  
        System.Windows.Forms.SaveFileDialog _fd = new System.Windows.Forms.SaveFileDialog();
          // set the properties of the Dialog

         fd.Title = “ Please select the location to save the file “;
          fd.FileName = “[ Select the folder
-]“;
  
        fd.Filter = “Library|no.files”; // set the options and only choose Library
  
        // Display the Dialog
  
        if (_fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  
            {
  
            // Get the result the uses chose .
  
            string dir_path = System.IO.Path.GetDirectoryName(_fd.FileName);
  
            if (dir_path != null && dir_path.Length > 0)
                  {

                         strPath = dir_path;
  
                }
  
            }
  
            //use the path the users chose to do subsequent process
      }

 

  In addition to User Interface APIs, we’ll pay more attention to Shell API. With Shell API, we could perform management in libraries .In fact, we could modify the file .library-ms, and the system will read the information from the file to reorganize the data in libraries after the file is modified. This group Shell API has packed a number of .com objects. We could manipulate libraries with these objects, of which there are several ones in common usage below:

 IShellLink: this object could be a file, a folder or a link to the executable file.

IShellFolder: this object is to represent a folder object.

IShellLibrary:

Besides, Shell APIs also provide multiple auxiliary functions, which are used to manipulate the libraries .For example:

1.     Create a library and open a library that already exists.

2.     Add the folder to the library or delete a folder in library.

3.     Attain a folder list of a library.

4.     Attain or set the options of the library.

5.     Attain or set the icon of the library.

Through these Shell APIs, we can completely manipulate the library in the Operating System.

 

 

 

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress

Close
E-mail It