VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxService/testcase/tstUserInfo.cpp

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/* $Id: tstUserInfo.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * Test case for correct user environment.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#ifdef RT_OS_WINDOWS
33# include <iprt/win/windows.h>
34# include <iprt/win/shlobj.h>
35#endif
36
37#include <iprt/initterm.h>
38#include <iprt/path.h>
39#include <iprt/env.h>
40#include <iprt/stream.h>
41#include <iprt/string.h>
42#include <VBox/log.h>
43#include <VBox/version.h>
44#include <VBox/VBoxGuestLib.h>
45
46
47int main()
48{
49 /*
50 * Init globals and such.
51 */
52 RTR3InitExeNoArguments(0);
53
54 int rc = VbglR3Init();
55 if (RT_FAILURE(rc))
56 {
57 RTPrintf("VbglR3Init failed with rc=%Rrc.\n", rc);
58 return -1;
59 }
60#ifdef RT_OS_WINDOWS
61 WCHAR wszPath[MAX_PATH];
62 HRESULT hRes = SHGetFolderPathW(0, CSIDL_APPDATA, 0, 0, wszPath);
63
64 if (SUCCEEDED(hRes))
65 {
66 RTPrintf("SHGetFolderPathW (CSIDL_APPDATA) = %ls\n", wszPath);
67 hRes = SHGetFolderPathW(0, CSIDL_PERSONAL, 0, 0, wszPath);
68 if (SUCCEEDED(hRes))
69 {
70 RTPrintf("SHGetFolderPathW (CSIDL_PERSONAL) = %ls\n", wszPath);
71 }
72 else
73 RTPrintf("SHGetFolderPathW (CSIDL_PERSONAL) returned error: 0x%x\n", hRes);
74 }
75 else
76 RTPrintf("SHGetFolderPathW (CSIDL_APPDATA) returned error: 0x%x\n", hRes);
77
78 if (FAILED(hRes))
79 rc = RTErrConvertFromWin32(hRes);
80
81 /* Dump env bits. */
82 RTPrintf("Environment:\n\n");
83 RTPrintf("APPDATA = %s\n", RTEnvGet("APPDATA"));
84#endif
85 return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
86}
87
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use