1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #pragma once 29 30 #ifdef _UWINAPI_ 31 # define _KERNEL32_ 32 # define _USER32_ 33 # define _SHELL32_ 34 #endif 35 36 #ifndef _WINDOWS_ 37 #ifdef _MSC_VER 38 # pragma warning(push,1) /* disable warnings within system headers */ 39 #endif 40 # include <windows.h> 41 #ifdef _MSC_VER 42 # pragma warning(pop) 43 #endif 44 #endif 45 46 #ifdef __MINGW32__ 47 #include <basetyps.h> 48 #ifdef _UWINAPI_ 49 #define WINBASEAPI 50 #endif 51 #endif 52 53 /** GetUserDomain 54 55 The GetUserDomain function retrieves the name of the NT domain the user is 56 logged in. 57 58 Parameters 59 @param lpBuffer 60 [out] Pointer to a buffer that receives a null-terminated string 61 containing the domain name. 62 @param nBufferSize 63 [in] Specifies the size, in TCHARs, of the buffer pointed to 64 by the lpBuffer parameter. 65 66 67 Return Values 68 @return 69 If the function succeeds, the return value is the number of TCHARs stored 70 into the buffer pointed to by lpBuffer, not including the terminating 71 null character. 72 73 If the domain name can't be retrieved, the return value is zero. 74 75 If the buffer pointed to by lpBuffer is not large enough, the return value 76 is the buffer size, in TCHARs, required to hold the value string and its 77 terminating null character. 78 79 Remarks 80 Windows 95/98/Me: If the user is not logged in onto a NT domain server 81 the name of the workgroup is returned. 82 83 Requirements 84 Windows NT/2000/XP: Included in Windows NT 4 and later. 85 Windows 95/98/Me: Included in Windows 95 and later. 86 Header: Declared in Uwinapi.h; include Uwinapi.h. 87 Library: Use Uwinapi.lib. 88 Unicode: Implemented as Unicode and ANSI versions on Windows 95/98/Me/NT/2000/XP. 89 90 See Also 91 @see 92 */ 93 94 EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainA( LPSTR lpBuffer, DWORD nBuffserSize ); 95 EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainW( LPWSTR lpBuffer, DWORD nBuffserSize ); 96 97 #ifdef UNICODE 98 #define GetUserDomain GetUserDomainW 99 #else 100 #define GetUserDomain GetUserDomainA 101 #endif 102 103 EXTERN_C WINBASEAPI DWORD WINAPI GetProcessId( HANDLE hProcess ); 104 105 /* macro that calculates the count of elements of a static array */ 106 107 #define elementsof(buf) (sizeof(buf) / sizeof((buf)[0])) 108 109 #ifdef __cplusplus 110 111 inline bool IsValidHandle(HANDLE handle) 112 { 113 return handle != INVALID_HANDLE_VALUE && handle != NULL; 114 } 115 116 #else /* __cplusplus */ 117 118 #define IsValidHandle(Handle) ((DWORD)(Handle) + 1 > 1) 119 120 #endif /* __cplusplus */ 121 122