http://code.google.com/p/excellibrary/ for excel
For Java,
http://poi.apache.org/
For Word, we have purchased some API from Aspose, but ours is the Java version of course. You would have to purchase the .NET version.
www.aspose.com
For PDF, we use iText currently.
http://itextpdf.com/
Thursday, May 27, 2010
Wednesday, May 26, 2010
Batch files
http://www.aumha.org/a/batches.php good link for batch file
/wait for process to be done
start /wait C:\WINDOWS\system32\MsiExec.exe /x {D74E7F02-026E-45C6-84C7-93D74F5BB0B1} /qb
/wait for process to be done
start /wait C:\WINDOWS\system32\MsiExec.exe /x {D74E7F02-026E-45C6-84C7-93D74F5BB0B1} /qb
Tuesday, May 25, 2010
Get installed application and extract msi to get product version
public static string GetInstalledApps()
{
//Declare the string to hold the list:
string Application = null;
//The registry key:
string SoftwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey))
{
//Let's go through the registry keys and get the info we need:
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
//If the key has value, continue, if not, skip it:
if (!(sk.GetValue("DisplayName") == null))
{
//get the version string
if (sk.GetValue("InstallLocation") == null)
Application += sk.GetValue("DisplayName") + " - Install path not known\n"; //Nope, not here.
else
Application += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "\n"; //Yes, here it is...
}
}
catch (Exception ex)
{
//exception
}
}
}
}
return Application;
}
///this is to get the current version of msi file
public static int GetCurrVersions(string inputFile)
{
// Get the type of the Windows Installer object
Type installerType = Type.GetTypeFromProgID("WindowsInstaller.Installer");
// Create the Windows Installer object
Installer installer = (Installer)Activator.CreateInstance(installerType);
// Open the MSI database in the input file
Database database = installer.OpenDatabase(inputFile, MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);
// Open a view on the Property table for the version property
View dataView = database.OpenView("SELECT * FROM Property WHERE Property = 'ProductVersion'");
// Execute the view query
dataView.Execute(null);
// Get the record from the view
Record dataRecord = dataView.Fetch();
// Get the version from the data
string version = dataRecord.get_StringData(2);
//close the view
dataView.Close();
}
Query LINQ
static void DisplayInstalledApplications()
{
string registryKey =
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (Microsoft.Win32.RegistryKey key =
Registry.LocalMachine.OpenSubKey(registryKey))
{
var query = from a in
key.GetSubKeyNames()
let r = key.OpenSubKey(a)
select new
{
Application = r.GetValue("DisplayName")
};
foreach (var item in query)
{
if (item.Application != null)
Console.WriteLine(item.Application);
}
}
}
{
//Declare the string to hold the list:
string Application = null;
//The registry key:
string SoftwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey))
{
//Let's go through the registry keys and get the info we need:
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
//If the key has value, continue, if not, skip it:
if (!(sk.GetValue("DisplayName") == null))
{
//get the version string
if (sk.GetValue("InstallLocation") == null)
Application += sk.GetValue("DisplayName") + " - Install path not known\n"; //Nope, not here.
else
Application += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "\n"; //Yes, here it is...
}
}
catch (Exception ex)
{
//exception
}
}
}
}
return Application;
}
///this is to get the current version of msi file
public static int GetCurrVersions(string inputFile)
{
// Get the type of the Windows Installer object
Type installerType = Type.GetTypeFromProgID("WindowsInstaller.Installer");
// Create the Windows Installer object
Installer installer = (Installer)Activator.CreateInstance(installerType);
// Open the MSI database in the input file
Database database = installer.OpenDatabase(inputFile, MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);
// Open a view on the Property table for the version property
View dataView = database.OpenView("SELECT * FROM Property WHERE Property = 'ProductVersion'");
// Execute the view query
dataView.Execute(null);
// Get the record from the view
Record dataRecord = dataView.Fetch();
// Get the version from the data
string version = dataRecord.get_StringData(2);
//close the view
dataView.Close();
}
Query LINQ
static void DisplayInstalledApplications()
{
string registryKey =
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (Microsoft.Win32.RegistryKey key =
Registry.LocalMachine.OpenSubKey(registryKey))
{
var query = from a in
key.GetSubKeyNames()
let r = key.OpenSubKey(a)
select new
{
Application = r.GetValue("DisplayName")
};
foreach (var item in query)
{
if (item.Application != null)
Console.WriteLine(item.Application);
}
}
}
Thursday, May 13, 2010
Visual Studio Environment
Choose a different settings by going to Tools menu, choose import and export settings and then choose reset all settings
Wednesday, May 5, 2010
Visual Studio, Configuration Manager
Configuration manager not able to check on an item, verify if it's readonly solution or it checked out or not
Subscribe to:
Posts (Atom)