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