Utilizzare il Log Parser con C#.

Da un annuncio Microsoft che evidentemente non avevo letto con attenzione, avevo sentito parlare della possibilità di usare una query “simil sql” per fare una ricerca sul registro di configurazione.

 

Ho scoperto (magari ero solo io che non lo sapevo) che non solo consente di fare delle ricerche sul registro ma anche su file xml, csv, il file system e Active Directory (a questo punto mi sono fatto un nodone per ricordarmi di provare assolutamente questo tool).

 

Ho trovato questo tip dell’MVP “Willy Denoyette” che spiega come fare per fare delle ricerche sul registro:

 

using System;

using System.Runtime.InteropServices;

using LogQuery = Interop.MSUtil.LogQueryClass;

using RegistryInputFormat = Interop.MSUtil.COMRegistryInputContextClass;

using RegRecordSet = Interop.MSUtil.ILogRecordset;

 

class Program

{

  public static void Main()

  {

    RegRecordSet rs = null;

    try

    {

      LogQuery qry = new LogQuery();

      RegistryInputFormat registryFormat = new RegistryInputFormat();

      string query = @"SELECT Path from WHERE Value='VisualStudio'";

      rs = qry.Execute(query, registryFormat);

      for(; !rs.atEnd(); rs.moveNext())

         Console.WriteLine(rs.getRecord().toNativeString(","));

    }

    finally

    {

      rs.close();

    }

  }

}

 

Per potelo usare è necessario scaricare e installare il  Log Parser da Microsoft .

E’ necessario inoltre generare un “Interop Assembly” a partire dal “Logparser.dll COM server” mediante il comando:

tlbimp "C:\Programmi\Log Parser 2.2\LogParser.dll" /out:Interop.MSUtil.dll

 

Impostare correttamente la versione del Log Parser presente nel proprio computer.

Print | posted on lunedì 27 febbraio 2006 23.36

Feedback

# re: Utilizzare il Log Parser con C#.

Left by Luca at 20/04/2009 17.06
Gravatar Ma se faccio un progetto c# che sfrutta le dll, in ogni PC che lo utilizza è necessario avere installato LogParser?

Your comment:





 
Please add 6 and 5 and type the answer here:

Copyright © Luciano Bastianello

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski