1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #pragma once
25
26 #ifdef _UWINAPI_
27 # define _KERNEL32_
28 # define _USER32_
29 # define _SHELL32_
30 #endif
31
32 #ifndef _WINDOWS_
33 #ifdef _MSC_VER
34 # pragma warning(push,1) /* disable warnings within system headers */
35 #endif
36 # include <windows.h>
37 #ifdef _MSC_VER
38 # pragma warning(pop)
39 #endif
40 #endif
41
42 #ifdef __MINGW32__
43 #include <basetyps.h>
44 #ifdef _UWINAPI_
45 #define WINBASEAPI
46 #endif
47 #endif
48
49 /** GetUserDomain
50
51 The GetUserDomain function retrieves the name of the NT domain the user is
52 logged in.
53
54 Parameters
55 @param lpBuffer
56 [out] Pointer to a buffer that receives a null-terminated string
57 containing the domain name.
58 @param nBufferSize
59 [in] Specifies the size, in TCHARs, of the buffer pointed to
60 by the lpBuffer parameter.
61
62
63 Return Values
64 @return
65 If the function succeeds, the return value is the number of TCHARs stored
66 into the buffer pointed to by lpBuffer, not including the terminating
67 null character.
68
69 If the domain name can't be retrieved, the return value is zero.
70
71 If the buffer pointed to by lpBuffer is not large enough, the return value
72 is the buffer size, in TCHARs, required to hold the value string and its
73 terminating null character.
74
75 Remarks
76 Windows 95/98/Me: If the user is not logged in onto a NT domain server
77 the name of the workgroup is returned.
78
79 Requirements
80 Windows NT/2000/XP: Included in Windows NT 4 and later.
81 Windows 95/98/Me: Included in Windows 95 and later.
82 Header: Declared in Uwinapi.h; include Uwinapi.h.
83 Library: Use Uwinapi.lib.
84 Unicode: Implemented as Unicode and ANSI versions on Windows 95/98/Me/NT/2000/XP.
85
86 See Also
87 @see
88 */
89
90 EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainA( LPSTR lpBuffer, DWORD nBuffserSize );
91 EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainW( LPWSTR lpBuffer, DWORD nBuffserSize );
92
93 #ifdef UNICODE
94 #define GetUserDomain GetUserDomainW
95 #else
96 #define GetUserDomain GetUserDomainA
97 #endif
98
99 EXTERN_C WINBASEAPI DWORD WINAPI GetProcessId( HANDLE hProcess );
100
101 /* macro that calculates the count of elements of a static array */
102
103 #define elementsof(buf) (sizeof(buf) / sizeof((buf)[0]))
104
105 #ifdef __cplusplus
106
IsValidHandle(HANDLE handle)107 inline bool IsValidHandle(HANDLE handle)
108 {
109 return handle != INVALID_HANDLE_VALUE && handle != NULL;
110 }
111
112 #else /* __cplusplus */
113
114 #define IsValidHandle(Handle) ((DWORD)(Handle) + 1 > 1)
115
116 #endif /* __cplusplus */
117
118