Fix subclassing to support nested messages.
[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 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winnls.h"
32 #include "winreg.h"
33 #include "winerror.h"
34
35 #include "wine/library.h"
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
39
40 /******************************************************************************
41  * GetUserNameA [ADVAPI32.@]
42  *
43  * Get the current user name.
44  *
45  * PARAMS
46  *  lpszName [O]   Destination for the user name.
47  *  lpSize   [I/O] Size of lpszName.
48  *
49  * RETURNS
50  *  Success: The length of the user name, including terminating NUL.
51  *  Failure: ERROR_MORE_DATA if *lpSize is too small.
52  */
53 BOOL WINAPI
54 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
55 {
56   size_t len;
57   const char *name = wine_get_user_name();
58
59   /* We need to include the null character when determining the size of the buffer. */
60   len = strlen(name) + 1;
61   if (len > *lpSize)
62   {
63     SetLastError(ERROR_MORE_DATA);
64     *lpSize = len;
65     return 0;
66   }
67
68   *lpSize = len;
69   strcpy(lpszName, name);
70   return 1;
71 }
72
73 /******************************************************************************
74  * GetUserNameW [ADVAPI32.@]
75  *
76  * See GetUserNameA.
77  */
78 BOOL WINAPI
79 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
80 {
81     const char *name = wine_get_user_name();
82     DWORD len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
83
84     if (len > *lpSize)
85     {
86         SetLastError(ERROR_MORE_DATA);
87         *lpSize = len;
88         return FALSE;
89     }
90
91     *lpSize = len;
92     MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, len );
93     return TRUE;
94 }
95
96 /******************************************************************************
97  * GetCurrentHwProfileA [ADVAPI32.@]
98  *
99  * Get the current hardware profile.
100  *
101  * PARAMS
102  *  pInfo [O] Destination for hardware profile information.
103  *
104  * RETURNS
105  *  Success: TRUE. pInfo is updated with the hardware profile details.
106  *  Failure: FALSE.
107  */
108 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
109 {
110         FIXME("(%p) semi-stub\n", pInfo);
111         pInfo->dwDockInfo = DOCKINFO_DOCKED;
112         strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
113         strcpy(pInfo->szHwProfileName,"Wine Profile");
114         return 1;
115 }
116
117 /******************************************************************************
118  * AbortSystemShutdownA [ADVAPI32.@]
119  *
120  * Stop a system shutdown if one is in progress.
121  *
122  * PARAMS
123  *  lpMachineName [I] Name of machine to not shutdown.
124  *
125  * RETURNS
126  *  Success: TRUE.
127  *  Failure: FALSE.
128  *
129  * NOTES
130  *  The Wine implementation of this function is a harmless stub.
131  */
132 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
133 {
134     TRACE("stub %s (harmless)\n", lpMachineName);
135     return TRUE;
136 }
137
138 /******************************************************************************
139  * AbortSystemShutdownW [ADVAPI32.@]
140  *
141  * See AbortSystemShutdownA.
142  */
143 BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
144 {
145     TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
146     return TRUE;
147 }
148
149 /******************************************************************************
150  * InitiateSystemShutdownExA [ADVAPI32.@]
151  */
152 BOOL WINAPI InitiateSystemShutdownExA( LPSTR lpMachineName, LPSTR lpMessage,
153          DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
154          DWORD dwReason)
155 {
156      FIXME("%s %s %ld %d %d %ld\n", debugstr_a(lpMachineName),
157             debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
158             bRebootAfterShutdown, dwReason);
159      return TRUE;
160
161
162 /******************************************************************************
163  * InitiateSystemShutdownExA [ADVAPI32.@]
164  */
165 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
166          DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
167          DWORD dwReason)
168 {
169      FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName),
170             debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
171             bRebootAfterShutdown, dwReason);
172      return TRUE;
173