Following the code in this MSDN blog, i have come up with the following code in C#
using Shell32; //Browse to C:\Windows\System32\shell32.dll
private void GetInstalledPrograms()
{
Shell shell = new Shell();
Shell objShell = shell.Application;
string folderName = @"::{26EE0668-A00A-44D7-9371-BEB064C98683}\8\" +
"::{7B81BE6A-CE2B-4676-A29E-EB907A5126C5}";
var objProgramList = objShell.NameSpace(folderName);
if (objProgramList != null)
{
MessageBox.Show(objProgramList.Items().ToString());
}
else
{
MessageBox.Show("Null");
}
}
For what ever reason, objProgramList
is null
. The odd thing is, with the following powershell code, I get exactly what I'm looking for! I don't know what I'm doing wrong. To me, both examples of my code are identical...
$Shell = New-Object -ComObject Shell.Application
$folderName = "::{26EE0668-A00A-44D7-9371-BEB064C98683}\8\::{7B81BE6A-CE2B-4676-A29E- EB907A5126C5}"
$folder = $Shell.NameSpace($folderName)
if($folder)
{
$folder.Items()
}