I have this piece of code that works very well and gives me the path the user's start menu:
Dim oShell As Object = CreateObject("Shell.Application")
MsgBox(oShell.NameSpace(11).Self.Path)
This obviously uses late binding. Now say I want to do this in C#, or in VB.NET strict mode, neither of which support this kind of syntax with late binding.
Is this possible? How?
Thanks for you help!
If you want to solve this the COM way you have to figure out, which COM reference to add in your VB project.
Open regedit and navigate to
HKEY_CLASSES_ROOT\<class id>\CLSID
, i.e.and you will find the class id which uniquely identifies the COM component.
Under
HKEY_CLASSES_ROOT\CLSID
you can now look up which file is behind the COM component:shows the following value:
Now go to Visual Studio, and add a reference to this file (on the Browse tab of the Add References dialog). If you open up the projects properties, you will actually see that the nice name of the COM component added is Microsoft Shell Controls and Automation.
Once the reference is added you can use the
Shell.Application
object as follows:A version in C# would look as follows:
However, if you simply need to retrieve the location of the Start Menu folder you can do the same directly in .NET using