473,378 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

VB.NET variant arrays

Hell

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
I'm pretty stuck. When I try to collect the installed software via a
call to EnumKey, I get a type mismatch (the exact erro
is: "System.Runtime.InteropServices.COMException (0x80041005): Typ
mismatch"

The code that causes the problem is below

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

Here's the code

Private Sub testsub(
Dim HKEY_LOCAL_MACHINE As Long = &H8000000
Dim sNames() As Objec
Dim sPath As Strin
Dim objLocator, objWMI, objRegistry As Objec

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

sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninsta ll

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

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

someObject.someMethod(someVariantArray

Thank
RF
Nov 20 '05 #1
1 5739
Mattias,

Thank you! Your advise was 100% dead on! The problem has been fixed!
----- Mattias Sjögren wrote: -----
Probably because HKEY_LOCAL_MACHINE is declared as Long, which is 64
bits in VB.NET unlike VB6 where it was 32 bits.
That said, I'd recommend you to use the Microsoft.Win32.Registry

classes for registry access instead.


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 20 '05 #2

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

Similar topics

5
by: Matt Smith | last post by:
Hi, all. Just a quick question, when setting a COM process to read a value from a pre-defined register index, I think, I have to change the variable that the value will be returned to (as I have...
2
by: Thilanga | last post by:
Hi, I want to access a VARIANT array returned by a method in VC++, that is supposed to be a long array. Can anybody suggest me a way of access this array and get the values in it. ...
0
by: Andrew S. Giles | last post by:
Helo all, I have a standalone unmanaged C++ application that makes a call on another standalone COM server, which raises an event that should be handled in C#. I am trying to send: unsigned...
19
by: Jon Davis | last post by:
Hi guys! Just wanted to let you all know that I created a Variant structure, inspired by the old VB6 days. This is written in C#, but you can build a CLR/.NET class library assembly and reference...
0
by: Michael Moreno | last post by:
Hello, I do not find the solution on how to convert this code into .Net public function MyFunc() as variant Dim R as Variant Redim R(0 to 10) as double MyFunc = R end function
2
by: louis | last post by:
I often read a recordset (ADO) into a variant array so that the array can contain text, currency, boolean, etc. VB.Net does not allow variants and the object type gives errors during conversion...
1
by: gilnux | last post by:
Hi all I've got nearly 2 years experience programming in C and image processing. Now I have to migrate one of my applications to a MFC interface. I am having problems with the VARIANT variable....
4
by: buzzluck68 | last post by:
Hello, I am having trouble upgrading my VB apps to .net. When i started at my company there was a dll created here in vb6, and i need to use that dll for many functions that would take too much...
2
by: Simply_Red | last post by:
I'm using VC6. i have a DLL written in VC6 and used by VB6( and VBA Excel), i use SafeArray as parameter, the array is created(declared), in VB and C++ fill it. now i need VC++ to get an array...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.