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