|
Also you may consider using property to make it neat.
modified 17-Jul-19 21:02pm.
|
|
|
|
|
Hi!
How do we retrieve all the installed softwares in WMI? All means all the softwares being installed in the computer. I used win32_Product yet it only retrieves those microsoft softwares and it even displays everything added to that software like an update.
The following are the needed information:
Softwarename
InstallDate
SotwarePath
AllotedLocationType
RegistryPath
ExecutableFilename
LastUsed
TotalUsageDurationMins
IsUninstalled
IsHotfix
IsServicePack
isUnauthorized
Please help.
Thanks.
-- modified at 7:18 Thursday 16th August, 2007
|
|
|
|
|
You can enumerate keys for path...
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
..and then look for DisplayName, UninstallString and other values as suited.
If you get to know a better way out please do let me know as well
Cheers
H.
|
|
|
|
|
Have a look at my response[^]. At the bottom of it is the WMI query against the Win32_Product class that you can use, it's much simpler than enumerating over the registry keys.
|
|
|
|
|
Using WMI isn't the simplest thing to do from managed code. If you search Google, you'll find a lot of information. Here is sample code from a message[^] in the microsft.public.dotnet.framework.wmi newsgroup:
const uint HKEY_LOCAL_MACHINE = unchecked((uint)0x80000002);
ManagementClass wmiRegistry = new ManagementClass("root/default", "StdRegProv", null);
string keyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
object[] methodArgs = new object[] {HKEY_LOCAL_MACHINE, keyPath, null};
uint returnValue = (uint)wmiRegistry.InvokeMethod("EnumKey", methodArgs);
Console.WriteLine("Executing EnumKey() returns: {0}", returnValue);
if (null != methodArgs[2])
{
string[] subKeys = methodArgs[2] as String[];
if (subKeys == null) return;
ManagementBaseObject inParam = wmiRegistry.GetMethodParameters("GetStringValue");
inParam["hDefKey"] = HKEY_LOCAL_MACHINE;
string keyName = "";
foreach(string subKey in subKeys)
{
keyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + subKey;
keyName = "DisplayName";
inParam["sSubKeyName"] = keyPath;
inParam["sValueName"] = keyName;
ManagementBaseObject outParam = wmiRegistry.InvokeMethod("GetStringValue", inParam, null);
if ((uint)outParam["ReturnValue"] == 0)
Console.WriteLine(outParam["sValue"]);
}
} This is essentially just enumerating over the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ registry key, so you can use the normal .NET registry classes to do the same thing without WMI.
Using the Win32_Product class, you would want to do something like this:
ManagementObjectSearcher products = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
foreach (ManagementObject product in products.Get())
{
Console.WriteLine("Software name: {0}", product.Name);
Console.WriteLine("Install date: {0}", product.InstallDate);
...
} The properties you list aren't all included in the Win32_Product[^] class, so you will probably need to do additional queries against other objects to get all of the information.
|
|
|
|
|
how about if we will display the installdate and installlocation using the latter code? or using the registry?
if inParam["sValueName"] = keyName is used to get the Displayname, how about the rest of the values? like installdate, softwarepath and the rest of the values?
|
|
|
|
|
toink toink wrote: how about if we will display the installdate and installlocation using the latter code? or using the registry?
What code are you referring to here?
toink toink wrote: if inParam["sValueName"] = keyName is used to get the Displayname, how about the rest of the values? like installdate, softwarepath and the rest of the values?
It sounds like you would probably do better to use this
ManagementObjectSearcher products = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
foreach (ManagementObject product in products.Get())
{
Console.WriteLine("Software name: {0}", product.Name);
Console.WriteLine("Install date: {0}", product.InstallDate);
...
}
|
|
|
|
|
Hi,
I have a DataGridView control with one column as ComboBox control.
I want to raise the event "SelectedValueChanged" of combo box.
How to do this. Please help.
Thanks & Regards,
nas
|
|
|
|
|
read an article on deploying events in C# applications over MSDN or search google.
write this line in your constructor.
dataGridView1.SelectedValueChanged+=<then press="" the="" tab="" key="" twice="" you'll="" get="" right="" thing="" in="" here="">then you start coding in the function made for the event handler
Rocky
|
|
|
|
|
Hi Rocky,
Thanks for reply.
Actually in DataGridView we can make any Column-Type as controls (Button,ComboBox, CheckBox...).
So i have selected one column of DGV as ComboBox. But this ComboBox differs from the normal ComboBox control.
By coding i want to access the ComboBox control of the DGV. 
|
|
|
|
|
OK
I know ur talking abt the datagridviewcombobox control right? try using the event 'CellValueChanged' on the dGV and in that you can get the column as
if(e.columnIndex == yourdgvcomboboxname.ColumnIndex)
{
//perform you task
}
and c if this things works for u or not incaseif it does give this msg and full rating
|
|
|
|
|
hello,
i am doing a project by C# language and using visual studio2005.Net.
Now i need a C# code which reads excel file and save all datas to corresponding SQL Server data base.
plz help me i will be grateful to u.
Shafik
|
|
|
|
|
You can read data from excel file by OLE DB provider and then save the data to database using ADO.NET
|
|
|
|
|
Dear sir,
would u tell me details...
|
|
|
|
|
This question has been asked and answered numerous times on this forum already.
Please check existing posts before submitting a question...
Paul
|
|
|
|
|
Here you go: excel using ole db[^]
If you need more information search for the keywords. You can find examples both on codeproject and google
|
|
|
|
|
I need some code or direction to write code the code to add my application at startup.
There are some software to add the application at startup by i need my own codding.
|
|
|
|
|
Have a look at Managing start-up section at http://www.codeproject.com/csharp/Trayminimizer.asp
|
|
|
|
|
You can add path of your app to these registry keys, and those will be executed at computer startup...
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
Cheers,
h.
|
|
|
|
|
hi all,
i have to insert sentences and images in word document in such a way that first page will contain only an image after that every page contains some sentences and one relevant image.That problem is that after inserting the sentence and image in the page i have to skip the rest of the space in that page and move to next page to insert other pair of sentence and image.
please help..
thanks
|
|
|
|
|
I want to make an application to make call via modem and receive them. I also want to implement to caller identification facility.
I need your's link's or hints to create such type of application.
which libraries i have to use and what is the technique to handle them.
|
|
|
|
|
In .Net 2.0 MS added the SerialPort class. That is one thing you will need to review before getting into the problem. You can use the serial port class to open a stream and send commands to the modem.
Phil
|
|
|
|
|
hi what just i want to know :
a connection string is already in the connection class and tested.
i am adding a combo box in a new form .....
how i can call or create a new instance to call the connection string before i write myConn.open
regards
|
|
|
|
|
What do you want to do exactly ? What connection class ? What does the combo box do ?
You can't call a string.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
the idaea is i want to fill the combo box data from the database( sql 2000)
i am working in c#
the connection string exist in a class
how i can open the connection from the form?
|
|
|
|