The Drottningholm castle is located 12 kilometres west of Stockholm Mariefred on the island of Ekerö. It takes 40 to 50 minutes by bus to reach Drottningholm. Alternatively, a daily ferry goes to Drottningholm from Stockholm until mid-Septemnber, and only during weekends for the rest of the year. See time table at Stromma here.
There is a small popular sheltered bay just across the Drottningholm palace where one can safely anchor.
You need to cross with the tender to a small pontoon giving access to Drottningholm castle.