.NET
  Home arrow .NET arrow Page 4 - Managing Windows Indexing Service with Vis...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Managing Windows Indexing Service with Visual Basic.NET Using COM
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2005-10-26

    Table of Contents:
  • Managing Windows Indexing Service with Visual Basic.NET Using COM
  • Getting “Indexing service” status information with COM and VB.NET
  • How to change the “start mode” of (or manage) indexing service
  • How to program the index catalogs

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Managing Windows Indexing Service with Visual Basic.NET Using COM - How to program the index catalogs


    (Page 4 of 4 )

    Make sure that “catalog” is totally different from the English word “Catalogue.”  Don’t try to mistake me in the spelling.  Now the interesting concept is working with “catalogs.”  This is not supported by WMI yet.  Now you can see the advantage of using COM (which is the Indexing Service itself).  If we wanted to view the catalog information or work (or manage) catalog information, it is a must to work with COM (at the moment).

    Now let us go through the code, which gives us the list of all catalogs available for indexing.

    Dim obj As New CIODMLib.AdminIndexServerClass
     
    Private Sub btnListCatalogs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListCatalogs.Click
            Dim isFoundCatalog As Boolean = obj.FindFirstCatalog
            Dim sCatalogList As String
            While isFoundCatalog
                Dim Catalog As CIODMLib.ICatAdm = obj.GetCatalog
                sCatalogList &= "Name: " & Catalog.CatalogName & ", "
                sCatalogList &= "Loc: " & Catalog.CatalogLocation &
    ", "
                sCatalogList &= "Running: " & Catalog.IsCatalogRunning & ControlChars.NewLine
                isFoundCatalog = obj.FindNextCatalog()
            End While
            MessageBox.Show(sCatalogList)
        End Sub

    “FindFirstCatalog”, “FindNextCatalog” and “GetCatalog” are the methods available in “AdminIndexServiceClass”, which are specially used to retrieve “catalog” information from “Indexing service”.  “FindFirstCatalog” and “FindNextCatalog” returns “true” if they find any catalog.  We can retrieve the currently found catalog using “GetCatalog”, which returns a reference to an object of type “ICatAdm” interface.  After getting the reference, you can play with properties “CatalogName”, “CatalogLocation”, “IsCatalogRunning” and so forth.

    Now let us examine how we add new catalogs or delete existing catalogs:

    Dim obj As New CIODMLib.AdminIndexServerClass
     
    Private Sub btnAddCatalog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddCatalog.Click
            obj.Stop()
            obj.AddCatalog("All ASP.NET articles", "D:\Library\DotNet\DotNetArticles\ASP.NET")
            obj.Start()
            MessageBox.Show("Succesfully Added")
        End Sub
     
    Private Sub btnDelCatalog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelCatalog.Click
            obj.Stop()
            obj.RemoveCatalog("All ASP.NET articles")
            obj.Start()
            MessageBox.Show("Succesfully Deleted")
        End Sub

    I introduced two new methods, “AddCatalog” and “RemoveCatalog” of the same class “AdminIndexServerClass”.  “AddCatalog” takes “catalog name” and “location” as parameters to add a new catalog to the indexing service.  “RemoveCatalog” takes only “catalog name” to remove it from Indexing Service.  One should understand that, before adding or removing a “catalog” from an Indexing Service, it is always recommended to follow a “stop-do-start” procedure.  And just observe how easy the above code is to understand.

    Summary

    I contributed this article especially to introduce you to .NET compatibility in interoperating with old Microsoft technologies like COM/DCOM and so on, and to penetrate further into managing the Indexing Service.  Even though I suggest you use WMI in certain scenarios, there are still some situations which WMI could not support.  This article confirms it. 

    Finally, if you ask me which is best (WMI or COM) to work with “Indexing Service”, I would suggest you implement both.  You work with COM if and only if you could not achieve the same things using WMI.  The order I suggest for picking the right path would be something like the following:

    • Native .NET support
    • WMI support
    • Web Service support
    • COM support

    Any comments, suggestions, bugs, errors, discussions, feedback etc. are highly appreciated at jag_chat@yahoo.com.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hello guys, now you can manage your indexing service right from VB.NET...have a...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT