// C++ with Microsoft extensions

#define _WIN32_DCOM

#include <objbase.h>
#include <shlobj.h>

// Это приложение выводит на экран
// окно свойств "Мой компьютер".

HRESULT hr;
LPMALLOC pMalloc = NULL;
LPSHELLFOLDER desktop = NULL;
LPCONTEXTMENU mnu = NULL;
LPITEMIDLIST pidlDrives = NULL;
CMINVOKECOMMANDINFO cmd;

void main( int argc, char *argv[])
{
  hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
  if( SUCCEEDED( hr ) )
  __try
  {
    hr = SHGetMalloc( &pMalloc );
    if( SUCCEEDED( hr ) )
    __try
    {
      hr = SHGetDesktopFolder( &desktop );
      if( SUCCEEDED( hr ) )
      __try
      {
        hr = SHGetSpecialFolderLocation( NULL, CSIDL_DRIVES, &pidlDrives );
        if( SUCCEEDED( hr ) )
        __try
        {
          hr = desktop->GetUIObjectOf( NULL, 1, const_cast<LPCITEMIDLIST*>(&pidlDrives), IID_IContextMenu, NULL, (void**) &mnu );
          if( SUCCEEDED( hr ) )
          __try
          {
            memset( & cmd, 0, sizeof( cmd ) );
            cmd.cbSize = sizeof( cmd );
            cmd.fMask = 0;
            cmd.hwnd = 0;
            cmd.lpVerb = "Properties";
            cmd.nShow = SW_SHOWNORMAL;
            hr = mnu->InvokeCommand( & cmd );
          }
          __finally
          {
            mnu->Release();
          }
        }
        __finally
        {
          pMalloc->Free( pidlDrives );
        }
      }
      __finally
      {
        desktop->Release();
      }
    }
    __finally
    {
      pMalloc->Release();
    }
  }
  __finally
  {
    CoUninitialize();
  }
}
// Delphi

program ShellB;

// Это приложение выводит на экран
// окно свойств "Мой компьютер".

uses
  Windows,
  ActiveX,
  ShlObj;

var
  pMalloc: IMalloc;
  desktop: IShellFolder;
  mnu: IContextMenu;
  hr: HRESULT;
  pidlDrives: PItemIDList;
  cmd: TCMInvokeCommandInfo;
begin
  hr := CoInitializeEx( nil, COINIT_MULTITHREADED );
  if SUCCEEDED( hr ) then
  try
    hr := SHGetMalloc( pMalloc );
    if SUCCEEDED( hr ) then
    try
      hr := SHGetDesktopFolder( desktop );
      if SUCCEEDED( hr ) then
      try
        hr := SHGetSpecialFolderLocation( 0, CSIDL_DRIVES, pidlDrives );
        if SUCCEEDED( hr ) then
        try
          hr := desktop.GetUIObjectOf( 0, 1, pidlDrives, IContextMenu, nil, Pointer(mnu) );
          if SUCCEEDED( hr ) then
          try
            FillMemory( @cmd, sizeof(cmd), 0 );
            with cmd do
            begin
              cbSize := sizeof( cmd );
              fMask := 0;
              hwnd := 0;
              lpVerb := PChar( 'Properties' );
              nShow := SW_SHOWNORMAL;
            end;
            hr := mnu.InvokeCommand( cmd );
          finally
            mnu := nil;
          end;
        finally
          pMalloc.Free( pidlDrives );
        end;
      finally
        desktop := nil;
      end;
    finally
      pMalloc := nil;
    end;
  finally
    CoUninitialize;
  end;
end.