Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / March 2004

Tip: Looking for answers? Try searching our database.

VB.NET WMI Detecting All installed apps problem.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob F - 23 Jan 2004 18:16 GMT
Hello

I'm wondering if anyone can shed some light on this?  I'm trying to enumerate the uninstall registry key (to display installed applications)
with VB.NET and WMI.  This function used to work in VB6.  I'm pretty stuck.  When I try to collect the installed software via a call to EnumKey,
I get a type mismatch (the exact error is: "System.Runtime.InteropServices.COMException (0x80041005): Type
mismatch")

The code that causes the problem is below.

The problem basically boils down to the fact that the EnumKey method of
StdRegProv wants the sNames as a variant array.  I'm passing it an
Object array, because VB.Net doesn't have variant types like VB6.  For the life
of me I cannot find any information on the Microsoft site, newsgroups, or anywhere else on the internet.  

Here's the code:

Private Sub testsub()
       Dim HKEY_LOCAL_MACHINE As Long = &H80000002
       Dim sNames() As Object
       Dim sPath As String
       Dim objLocator, objWMI, objRegistry As Object

       objLocator = CreateObject("WbemScripting.SWbemLocator")
       objWMI = objLocator.ConnectServer(target, "root\default")
       objWMI.Security_.ImpersonationLevel = 3 'Impersonate
       objRegistry = objWMI.Get("StdRegProv")

       sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

       objRegistry.EnumKey(HKEY_LOCAL_MACHINE, sPath, sNames) ' <---
Dies on this line
End Sub

And just so it's clear, it boils down to this situation: I need
someMethod to populate someVariantArray for me inside it.  Here's an
example:

someObject.someMethod(someVariantArray)
gary_milton - 07 Mar 2004 01:12 GMT
You need to remove the parenthesis from your 'sNames' declaration, so i
should read...

Dim sNames As Objec

-
gary_milto

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.