VirtualBox

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

Last change on this file since 32634 was 32634, checked in by vboxsync, 14 years ago

VBoxService: Added a simple testcase for guest user environment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/* $Id: tstUserInfo.cpp 32634 2010-09-20 12:00:44Z vboxsync $ */
2/** @file
3 * Test case for correct user environment.
4 */
5
6/*
7 * Copyright (C) 2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#ifdef RT_OS_WINDOWS
23# include <windows.h>
24# include <tchar.h>
25# include <stdio.h>
26# include <Shlobj.h>
27#endif
28
29#include <iprt/initterm.h>
30#include <iprt/path.h>
31#include <iprt/stream.h>
32#include <iprt/string.h>
33#include <VBox/log.h>
34#include <VBox/version.h>
35#include <VBox/VBoxGuestLib.h>
36
37
38int main()
39{
40 /*
41 * Init globals and such.
42 */
43 RTR3Init();
44
45 int rc = VbglR3Init();
46 if (RT_FAILURE(rc))
47 {
48 printf("VbglR3Init failed with rc=%Rrc.\n", rc);
49 return -1;
50 }
51#ifdef RT_OS_WINDOWS
52 TCHAR szPath[MAX_PATH];
53 HRESULT hRes = SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, szPath);
54
55 if (SUCCEEDED(hRes))
56 {
57 RTPrintf("SHGetFolderPathW (CSIDL_APPDATA) = %ls\n", szPath);
58 hRes = SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, szPath);
59 if (SUCCEEDED(hRes))
60 {
61 RTPrintf("SHGetFolderPathW (CSIDL_PERSONAL) = %ls\n", szPath);
62 }
63 else
64 RTPrintf("SHGetFolderPathW (CSIDL_PERSONAL) returned error: 0x%x", hRes);
65 }
66 else
67 RTPrintf("SHGetFolderPathW (CSIDL_APPDATA) returned error: 0x%x", hRes);
68
69 if (FAILED(hRes))
70 rc = RTErrConvertFromWin32(hRes);
71
72 if (RT_SUCCESS(rc))
73 {
74 /* Dump env bits. */
75 RTPrintf("Environment:\n\n");
76 RTPrintf("APPDATA = %s\n", getenv("APPDATA"));
77 }
78#endif
79 return VINF_SUCCESS(rc) ? 0 : -1;
80}
81
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette