~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Additions/common/VBoxService/testcase/tstUserInfo.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: tstUserInfo.cpp 32652 2010-09-21 07:04:49Z 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
 
 
38
int 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\n", hRes);
 
65
    }
 
66
    else
 
67
        RTPrintf("SHGetFolderPathW (CSIDL_APPDATA) returned error: 0x%x\n", hRes);
 
68
 
 
69
    if (FAILED(hRes))
 
70
        rc = RTErrConvertFromWin32(hRes);
 
71
 
 
72
    /* Dump env bits. */
 
73
    RTPrintf("Environment:\n\n");
 
74
    RTPrintf("APPDATA = %s\n", getenv("APPDATA"));
 
75
#endif
 
76
    return RT_SUCCESS(rc) ? 0 : 1;
 
77
}
 
78