@@ -163,7 +163,6 @@ public interface ISetupPropertyStore
163163
164164 [ Guid ( "42843719-DB4C-46C2-8E7C-64F1816EFD5B" ) ]
165165 [ CoClass ( typeof ( SetupConfigurationClass ) ) ]
166- [ TypeLibImportClass ( typeof ( SetupConfigurationClass ) ) ]
167166 [ ComImport ]
168167 public interface SetupConfiguration : ISetupConfiguration2 , ISetupConfiguration
169168 {
@@ -176,36 +175,27 @@ public class SetupConfigurationClass
176175 {
177176 }
178177
179- public static class Program
178+ public static class Main
180179 {
181- public static int Main ( string [ ] args )
180+ public static void Query ( )
182181 {
183- try
184- {
185- ISetupConfiguration query = new SetupConfiguration ( ) ;
186- ISetupConfiguration2 query2 = ( ISetupConfiguration2 ) query ;
187- IEnumSetupInstances e = query2 . EnumAllInstances ( ) ;
188- ISetupInstance2 [ ] rgelt = new ISetupInstance2 [ 1 ] ;
189- int pceltFetched ;
190- do
191- {
192- e . Next ( 1 , rgelt , out pceltFetched ) ;
193- if ( pceltFetched > 0 )
194- PrintInstance ( rgelt [ 0 ] ) ;
195- } while ( pceltFetched > 0 ) ;
196- return 0 ;
197- }
198- catch ( Exception ex )
199- {
200- Console . Error . WriteLine ( "Error 0x{0:x8}: {1}" , ex , ex . Message ) ;
201- return 1 ;
202- }
182+ ISetupConfiguration query = new SetupConfiguration ( ) ;
183+ ISetupConfiguration2 query2 = ( ISetupConfiguration2 ) query ;
184+ IEnumSetupInstances e = query2 . EnumAllInstances ( ) ;
185+ ISetupInstance2 [ ] rgelt = new ISetupInstance2 [ 1 ] ;
186+ int pceltFetched ;
187+ do
188+ {
189+ e . Next ( 1 , rgelt , out pceltFetched ) ;
190+ if ( pceltFetched > 0 )
191+ PrintInstance ( rgelt [ 0 ] ) ;
192+ } while ( pceltFetched > 0 ) ;
203193 }
204194
205195 private static void PrintInstance ( ISetupInstance2 setupInstance2 )
206196 {
207- Console . WriteLine ( "InstallationPath: {0}" , setupInstance2 . GetInstallationPath ( ) ) ;
208- Console . WriteLine ( "Product: {0}" , setupInstance2 . GetProduct ( ) . GetId ( ) ) ;
197+ Console . Write ( String . Format ( "InstallationPath: {0}\n " , setupInstance2 . GetInstallationPath ( ) ) ) ;
198+ Console . Write ( String . Format ( "Product: {0}\n " , setupInstance2 . GetProduct ( ) . GetId ( ) ) ) ;
209199 foreach ( ISetupPackageReference package in setupInstance2 . GetPackages ( ) )
210200 {
211201 if ( package . GetType ( ) != "Exe" ) continue ;
@@ -216,9 +206,8 @@ private static void PrintInstance(ISetupInstance2 setupInstance2)
216206 string sdkVer = parts [ 1 ] ;
217207 char [ ] chars = { '1' , '0' , '8' } ;
218208 if ( sdkVer . IndexOfAny ( chars ) == - 1 ) continue ;
219- Console . WriteLine ( "SDK: {0}" , sdkVer ) ;
209+ Console . Write ( String . Format ( "SDK: {0}\n " , sdkVer ) ) ;
220210 }
221- Console . WriteLine ( ) ;
222211 }
223212 }
224213}
0 commit comments