1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/XComponent.hpp>
21 #include <com/sun/star/registry/XSimpleRegistry.hpp>
23 #include <com/sun/star/system/XSystemShellExecute.hpp>
24 #include <cppuhelper/servicefactory.hxx>
26 #include <osl/file.hxx>
27 #include <rtl/ustring.hxx>
28 #include <sal/types.h>
29 #include <osl/diagnose.h>
34 #pragma warning(push, 1)
45 using namespace ::cppu
;
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::lang
;
49 using namespace com::sun::star::system
;
51 #define RDB_SYSPATH "D:\\Projects\\gsl\\shell\\wntmsci7\\bin\\applicat.rdb"
57 Reference
< XMultiServiceFactory
> g_xFactory
;
65 // int SAL_CALL main(int nArgc, char* Argv[], char* Env[] )
66 int SAL_CALL
main(int nArgc
, char* Argv
[], char* )
69 // get the global service-manager
75 // Get global factory for uno services.
76 OUString rdbName
= OUString( RDB_SYSPATH
);
77 Reference
< XMultiServiceFactory
> g_xFactory( createRegistryServiceFactory( rdbName
) );
79 // Print a message if an error occurred.
80 if ( g_xFactory
.is() == sal_False
)
82 OSL_FAIL("Can't create RegistryServiceFactory");
86 printf("Creating RegistryServiceFactory successful\n");
89 // try to get an Interface to a XFilePicker Service
92 Reference
< XSystemShellExecute
> xSysShExec(
93 g_xFactory
->createInstance("com.sun.star.system.SystemShellExecute"), UNO_QUERY
);
95 if ( !xSysShExec
.is() )
97 OSL_FAIL( "Error creating SystemShellExecute Service" );
101 //"c:\\winnt\\notepad.exe"
102 OUString cmd
= OUString::createFromAscii( Argv
[1] );
103 OUString param
= OUString::createFromAscii( Argv
[2] ); //c:\\winnt\\iis5.log
107 xSysShExec
->execute( cmd
, param
, atoi( Argv
[3] ) );
109 catch( SystemShellExecuteException
& )
111 OSL_FAIL( "Error executing system command" );
113 catch( IllegalArgumentException
& )
115 OSL_FAIL( "Invalid parameter" );
122 // Cast factory to XComponent
123 Reference
< XComponent
> xComponent( g_xFactory
, UNO_QUERY
);
125 // Print a message if an error occurred.
126 if ( xComponent
.is() == sal_False
)
128 OSL_FAIL("Error shuting down");
131 // Dispose and clear factory
132 xComponent
->dispose();
135 printf("Test successful\n");
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */