Documentation updates.
[wine] / dlls / advapi32 / advapi.c
1 /*
2  * Win32 advapi functions
3  *
4  * Copyright 1995 Sven Verdoolaege
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <errno.h>
25 #include <stdio.h>
26 #include <string.h>
27
28 #include "winbase.h"
29 #include "windef.h"
30 #include "winnls.h"
31 #include "winerror.h"
32
33 #include "wine/library.h"
34 #include "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
37
38 /******************************************************************************
39  * GetUserNameA [ADVAPI32.@]
40  *
41  * Get the current user name.
42  *
43  * PARAMS
44  *  lpszName [O]   Destination for the user name.
45  *  lpSize   [I/O] Size of lpszName.
46  *
47  * RETURNS
48  *  Success: The length of the user name, including terminating NUL.
49  *  Failure: ERROR_MORE_DATA if *lpSize is too small.
50  */
51 BOOL WINAPI
52 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
53 {
54   size_t len;
55   const char *name = wine_get_user_name();
56
57   /* We need to include the null character when determining the size of the buffer. */
58   len = strlen(name) + 1;
59   if (len > *lpSize)
60   {
61     SetLastError(ERROR_MORE_DATA);
62     *lpSize = len;
63     return 0;
64   }
65
66   *lpSize = len;
67   strcpy(lpszName, name);
68   return 1;
69 }
70
71 /******************************************************************************
72  * GetUserNameW [ADVAPI32.@]
73  *
74  * See GetUserNameA.
75  */
76 BOOL WINAPI
77 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
78 {
79     const char *name = wine_get_user_name();
80     DWORD len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
81
82     if (len > *lpSize)
83     {
84         SetLastError(ERROR_MORE_DATA);
85         *lpSize = len;
86         return FALSE;
87     }
88
89     *lpSize = len;
90     MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, len );
91     return TRUE;
92 }
93
94 /******************************************************************************
95  * GetCurrentHwProfileA [ADVAPI32.@]
96  *
97  * Get the current hardware profile.
98  *
99  * PARAMS
100  *  pInfo [O] Destination for hardware profile information.
101  *
102  * RETURNS
103  *  Success: TRUE. pInfo is updated with the hardware profile details.
104  *  Failure: FALSE.
105  */
106 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
107 {
108         FIXME("(%p) semi-stub\n", pInfo);
109         pInfo->dwDockInfo = DOCKINFO_DOCKED;
110         strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
111         strcpy(pInfo->szHwProfileName,"Wine Profile");
112         return 1;
113 }
114
115 /******************************************************************************
116  * AbortSystemShutdownA [ADVAPI32.@]
117  *
118  * Stop a system shutdown if one is in progress.
119  *
120  * PARAMS
121  *  lpMachineName [I] Name of machine to not shutdown.
122  *
123  * RETURNS
124  *  Success: TRUE.
125  *  Failure: FALSE.
126  *
127  * NOTES
128  *  The Wine implementation of this function is a harmless stub.
129  */
130 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
131 {
132     TRACE("stub %s (harmless)\n", lpMachineName);
133     return TRUE;
134 }
135
136 /******************************************************************************
137  * AbortSystemShutdownW [ADVAPI32.@]
138  *
139  * See AbortSystemShutdownA.
140  */
141 BOOL WINAPI AbortSystemShutdownW( LPCWSTR lpMachineName )
142 {
143     TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
144     return TRUE;
145 }