Click here to Skip to main content
15,889,810 members
Home / Discussions / C#
   

C#

 
QuestionCan we show an imageBox by toolTip? Pin
Mohammad Dayyan5-Sep-08 4:38
Mohammad Dayyan5-Sep-08 4:38 
AnswerRe: Can we show an imageBox by toolTip? Pin
vikas amin5-Sep-08 6:21
vikas amin5-Sep-08 6:21 
QuestionGetting application version numbers in C# Pin
Matt Fishbeck5-Sep-08 3:53
Matt Fishbeck5-Sep-08 3:53 
AnswerRe: Getting application version numbers in C# Pin
DaveyM695-Sep-08 4:04
professionalDaveyM695-Sep-08 4:04 
AnswerRe: Getting application version numbers in C# Pin
#realJSOP5-Sep-08 4:26
mve#realJSOP5-Sep-08 4:26 
GeneralRe: Getting application version numbers in C# Pin
Manas Bhardwaj5-Sep-08 4:28
professionalManas Bhardwaj5-Sep-08 4:28 
GeneralRe: Getting application version numbers in C# Pin
Matt Fishbeck5-Sep-08 4:50
Matt Fishbeck5-Sep-08 4:50 
GeneralRe: Getting application version numbers in C# [modified] Pin
#realJSOP5-Sep-08 5:14
mve#realJSOP5-Sep-08 5:14 
You'll have to use Interop services to check the version number of executables, and

Use WMI to get a list of installed applications (look at the Win32_Product class). There is a "Version" property available that gives you what you want.

BTW, there was no need for anyone to vote a 1 on my first response. That was pretty rude, considering nobody else has suggested a solution.

Here's some code from one of my own projects. The GetObjectPropertyString() method is one of several helper methods I wrote that serve no other purpose than to clean up the code that I'm actually working in. No messy exception handling, no conversions - just a function call.

//--------------------------------------------------------------------------------
private static string GetObjectPropertyString(ManagementObject mo, string name, string defaultValue)
{
	string value = defaultValue;
	try
	{
		value = mo[name].ToString();
	}
	catch (Exception ex)
	{
		if (ex != null) {}
#if DEBUG
		System.Diagnostics.Trace.WriteLine(string.Format("GetObjectPropertyString() EXCEPTION - looking for {0} property", name));
#endif
	}
	return value;
}


ManagementClass mc = new ManagementClass("Win32_Product");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
	string name = GetObjectPropertyString(mo, "Name", ""); // you can also use "Caption" or "Description"
	string version = GetObjectPropertyString(mo, "Version", "");
}



"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


modified on Friday, September 5, 2008 11:28 AM

GeneralRe: Getting application version numbers in C# Pin
Matt Fishbeck8-Sep-08 2:58
Matt Fishbeck8-Sep-08 2:58 
GeneralRe: Getting application version numbers in C# Pin
#realJSOP6-Sep-08 2:10
mve#realJSOP6-Sep-08 2:10 
GeneralRe: Getting application version numbers in C# Pin
Matt Fishbeck10-Sep-08 22:36
Matt Fishbeck10-Sep-08 22:36 
GeneralRe: Getting application version numbers in C# Pin
#realJSOP10-Sep-08 23:15
mve#realJSOP10-Sep-08 23:15 
GeneralRe: Getting application version numbers in C# Pin
Matt Fishbeck11-Sep-08 0:24
Matt Fishbeck11-Sep-08 0:24 
GeneralRe: Getting application version numbers in C# Pin
Matt Fishbeck5-Sep-08 5:15
Matt Fishbeck5-Sep-08 5:15 
QuestionRegular Expression Pin
netDeveloper5-Sep-08 3:46
netDeveloper5-Sep-08 3:46 
AnswerRe: Regular Expression Pin
c24235-Sep-08 4:51
c24235-Sep-08 4:51 
GeneralRe: Regular Expression Pin
netDeveloper5-Sep-08 4:53
netDeveloper5-Sep-08 4:53 
GeneralRe: Regular Expression Pin
User 66585-Sep-08 6:38
User 66585-Sep-08 6:38 
QuestionWebRequest object crashes program Pin
Filmxposer5-Sep-08 3:44
Filmxposer5-Sep-08 3:44 
QuestionHow to internationalize AssemblyInfo strings? Pin
bscaer5-Sep-08 3:33
bscaer5-Sep-08 3:33 
QuestionHow can an event handler update the text in a TextBox when the GUI-thread is sleeping? Pin
arnold_w5-Sep-08 3:16
arnold_w5-Sep-08 3:16 
AnswerRe: How can an event handler update the text in a TextBox when the GUI-thread is sleeping? Pin
DaveyM695-Sep-08 3:44
professionalDaveyM695-Sep-08 3:44 
AnswerRe: How can an event handler update the text in a TextBox when the GUI-thread is sleeping? Pin
Nicholas Butler5-Sep-08 6:03
sitebuilderNicholas Butler5-Sep-08 6:03 
GeneralRe: How can an event handler update the text in a TextBox when the GUI-thread is sleeping? Pin
arnold_w7-Sep-08 21:23
arnold_w7-Sep-08 21:23 
GeneralRe: How can an event handler update the text in a TextBox when the GUI-thread is sleeping? Pin
Nicholas Butler7-Sep-08 23:48
sitebuilderNicholas Butler7-Sep-08 23:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.