The GetWebSiteProperties method, given a server instance of a Web site, enumerates all Commerce Server sites under that Web site. The method returns an array of numbers representing all Commerce Server site instances.
AdminWebServer.GetCommerceSites(ServerInstance)
The GetCommerceSites method determines whether a site is a Commerce Server site by examining a reserved key in the metabase.
For a complete example, see AdminWebServer Object Overview.