473,508 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to obtain Product Code within a C# application?


Hi misters,

How I can do this in C# ??

Dim installer As Object

installer = CreateObject("WindowsInstaller.Installer")

Dim products As Object = installer.Products

For Each strProductCode As String In products

'Console.WriteLine(strProductCode)

Dim strProductName As String =
installer.ProductInfo(strProductCode, "InstalledProductName")

If strProductName = "Something" Then

'That's it.

End If

Next
Thanks !!!

--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.com/churrosoft
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft

Sep 26 '08 #1
6 4406
Alhambra Eidos Desarrollo a couché sur son écran :
Hi misters,

How I can do this in C# ??

Dim installer As Object

installer = CreateObject("WindowsInstaller.Installer")

Dim products As Object = installer.Products

For Each strProductCode As String In products

'Console.WriteLine(strProductCode)

Dim strProductName As String =
installer.ProductInfo(strProductCode, "InstalledProductName")

If strProductName = "Something" Then

'That's it.

End If

Next
Thanks !!!
Hi, i think this following code works, try it :

Type type = Type.GetType("Windows.Installer");

WindowsInstaller.Installer installer = Activator.CreateInstance(type);

foreach (string strProductCode in installer.Products)
{
Console.WriteLine(strProductCode);
string strProductName = installer.ProductInfo(strProductCode,
"InstalledProductName");
if (strProductCode == "Something")
{
}
}

--
Paul Musso
Sep 26 '08 #2
Type type = Type.GetType("Windows.Installer");

WindowsInstaller.Installer installer = Activator.CreateInstance(type);
thanks mister !!!

I need add some reference about Windows.Installer in my csproj ??? which
Reference, where the type WindowsInstaller.Installer contains within the
reference ?

How can I detect that Windows Installer is installed in my machine ??

Thanks again, mister.

Sep 26 '08 #3
By using CreateInstance or CreateObject, you don't need to add a reference.
You should check for an exception when calling this to see if the class is
not registered, but I believe there will be a windows installer on every
machine.

"Alhambra Eidos Desarrollo" wrote:
>
Type type = Type.GetType("Windows.Installer");

WindowsInstaller.Installer installer = Activator.CreateInstance(type);

thanks mister !!!

I need add some reference about Windows.Installer in my csproj ??? which
Reference, where the type WindowsInstaller.Installer contains within the
reference ?

How can I detect that Windows Installer is installed in my machine ??

Thanks again, mister.
Sep 26 '08 #4
Family Tree Mike avait prétendu :
By using CreateInstance or CreateObject, you don't need to add a reference.
You should check for an exception when calling this to see if the class is
not registered, but I believe there will be a windows installer on every
machine.

"Alhambra Eidos Desarrollo" wrote:
>>
>>Type type = Type.GetType("Windows.Installer");

WindowsInstaller.Installer installer = Activator.CreateInstance(type);

thanks mister !!!

I need add some reference about Windows.Installer in my csproj ??? which
Reference, where the type WindowsInstaller.Installer contains within the
reference ?

How can I detect that Windows Installer is installed in my machine ??

Thanks again, mister.
You must add a reference to "C:\Windows\System32\msi.dll"

Here is the C# code reviewed :

Type type = Type.GetType("Windows.Installer");

WindowsInstaller.Installer installer = (WindowsInstaller.Installer)
Activator.CreateInstance(type);

foreach (string strProductCode in installer.Products)
{
Console.WriteLine(strProductCode);
string strProductName = installer.get_ProductInfo(strProductCode,
"InstalledProductName");
if (strProductName == "Something")
{
}
}

--
Paul Musso
Sep 26 '08 #5
You are right, when casting to the WindowsInstaller.Installer type you need a
reference. If you are adding a reference though, why not just use:

WindowsInstaller.Installer installer = new WindowsInstaller.Installer();

"Paul Musso" wrote:
Family Tree Mike avait prétendu :
By using CreateInstance or CreateObject, you don't need to add a reference.
You should check for an exception when calling this to see if the class is
not registered, but I believe there will be a windows installer on every
machine.

"Alhambra Eidos Desarrollo" wrote:
>
Type type = Type.GetType("Windows.Installer");

WindowsInstaller.Installer installer = Activator.CreateInstance(type);

thanks mister !!!

I need add some reference about Windows.Installer in my csproj ??? which
Reference, where the type WindowsInstaller.Installer contains within the
reference ?

How can I detect that Windows Installer is installed in my machine ??

Thanks again, mister.

You must add a reference to "C:\Windows\System32\msi.dll"

Here is the C# code reviewed :

Type type = Type.GetType("Windows.Installer");

WindowsInstaller.Installer installer = (WindowsInstaller.Installer)
Activator.CreateInstance(type);

foreach (string strProductCode in installer.Products)
{
Console.WriteLine(strProductCode);
string strProductName = installer.get_ProductInfo(strProductCode,
"InstalledProductName");
if (strProductName == "Something")
{
}
}

--
Paul Musso
Sep 26 '08 #6
Exact, i just respected that he wrote in VB.

--
Paul Musso
Sep 26 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1811
by: comp.lang.php | last post by:
/** * Filter results according to given instruction * * @access private * @param object $result (reference) * @return object $filteredResult */ function &filterResults(&$result) { //...
3
1403
by: aww91 | last post by:
Need product information on IBM's Integration Integrator (I.I) for conversion of SyBase calls to UDB calls. Production allows for conversion of modules one-by-one and then when all modules are...
2
1136
by: Jesper | last post by:
Hi, Is there a clever way to get the number of instances started of an application within the same application. Is it possible to implement an event handler to key on the change in numbers of...
1
3766
by: BuddyWork | last post by:
Hello, When a particular user (has administrator rights) on a Windows 2000 Server SP4 tries to run any MSI's we get the message mentioned in the subject. If we logon with another user that has...
5
2052
by: OneFang | last post by:
Hi I hope I make sense here. I want to be able to obtain the name of the method that calls a method within my class. So If I have my class that has a method LogInfo() And my client code...
2
1644
by: Yarik | last post by:
Hello, I am not sure the subject of my post adequately describes the problem I am trying to solve, so I think a specific example would be helpful. Let's say there are XML descriptions of...
1
1096
by: FrankieBakerJr | last post by:
Hello I have an ASP.NET 2005 web application that I'd like to be able to determine it's full url from within code. Here's an example: My URL for this sample web site is:...
8
1325
by: ThunderMusic | last post by:
Hi, We need to serialize (binary) objects containing generic collections. The thing is, when we try to get the objects back (deserialize) with a different instance of the application, we receive...
2
2464
by: ME | last post by:
How would one obtain the parameter VALUES of a method that has already run? I can find the method using the StackTrace and StackFrame classes but once I find the method I would like to obtain the...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.