Fixed RtlIsTextUnicode prototype, and made it properly take into
[wine.git] / dlls / advapi32 / advapi.c
blobf6d10ce9c08c84f4f522dfaa395f651b48db3242
1 /*
2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
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.
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.
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
21 #include "config.h"
22 #include "wine/port.h"
24 #include <errno.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdarg.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winnls.h"
32 #include "winreg.h"
33 #include "winternl.h"
34 #include "winerror.h"
36 #include "wine/library.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
41 /******************************************************************************
42 * GetUserNameA [ADVAPI32.@]
44 * Get the current user name.
46 * PARAMS
47 * lpszName [O] Destination for the user name.
48 * lpSize [I/O] Size of lpszName.
50 * RETURNS
51 * Success: The length of the user name, including terminating NUL.
52 * Failure: ERROR_MORE_DATA if *lpSize is too small.
54 BOOL WINAPI
55 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
57 WCHAR *buffer;
58 BOOL ret;
59 DWORD sizeW = *lpSize * 2;
61 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, sizeW * sizeof(WCHAR) )))
63 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
64 return FALSE;
66 ret = GetUserNameW( buffer, &sizeW );
67 if (ret)
69 if (!(*lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpszName, *lpSize, NULL, NULL )))
71 *lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
72 SetLastError( ERROR_MORE_DATA );
73 ret = FALSE;
76 else *lpSize = sizeW * 2;
77 HeapFree( GetProcessHeap(), 0, buffer );
78 return ret;
81 /******************************************************************************
82 * GetUserNameW [ADVAPI32.@]
84 * See GetUserNameA.
86 BOOL WINAPI
87 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
89 const char *name = wine_get_user_name();
90 DWORD len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 );
92 if (len > *lpSize)
94 SetLastError(ERROR_MORE_DATA);
95 *lpSize = len;
96 return FALSE;
99 *lpSize = len;
100 MultiByteToWideChar( CP_UNIXCP, 0, name, -1, lpszName, len );
101 return TRUE;
104 /******************************************************************************
105 * GetCurrentHwProfileA [ADVAPI32.@]
107 * Get the current hardware profile.
109 * PARAMS
110 * pInfo [O] Destination for hardware profile information.
112 * RETURNS
113 * Success: TRUE. pInfo is updated with the hardware profile details.
114 * Failure: FALSE.
116 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
118 FIXME("(%p) semi-stub\n", pInfo);
119 pInfo->dwDockInfo = DOCKINFO_DOCKED;
120 strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
121 strcpy(pInfo->szHwProfileName,"Wine Profile");
122 return 1;
125 /******************************************************************************
126 * GetCurrentHwProfileW [ADVAPI32.@]
128 * See GetCurrentHwProfileA.
130 BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
132 FIXME("(%p)\n", pInfo);
133 return FALSE;
137 /**************************************************************************
138 * IsTextUnicode (ADVAPI32.@)
140 * Attempt to guess whether a text buffer is Unicode.
142 * PARAMS
143 * buf [I] Text buffer to test
144 * len [I] Length of buf
145 * flags [O] Destination for test results
147 BOOL WINAPI IsTextUnicode( LPCVOID buf, INT len, LPINT flags )
149 return RtlIsTextUnicode( buf, len, flags );
153 /******************************************************************************
154 * AbortSystemShutdownA [ADVAPI32.@]
156 * Stop a system shutdown if one is in progress.
158 * PARAMS
159 * lpMachineName [I] Name of machine to not shutdown.
161 * RETURNS
162 * Success: TRUE.
163 * Failure: FALSE.
165 * NOTES
166 * The Wine implementation of this function is a harmless stub.
168 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
170 TRACE("stub %s (harmless)\n", lpMachineName);
171 return TRUE;
174 /******************************************************************************
175 * AbortSystemShutdownW [ADVAPI32.@]
177 * See AbortSystemShutdownA.
179 BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
181 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
182 return TRUE;
185 /******************************************************************************
186 * InitiateSystemShutdownExA [ADVAPI32.@]
188 * Initiate a shutdown or optionally restart the computer.
190 * PARAMS
191 * lpMachineName [I] Network name of machine to shutdown.
192 * lpMessage [I] Message displayed in shutdown dialog box.
193 * dwTimeout [I] Number of seconds dialog is displayed before shutdown.
194 * bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
195 * displayed requesting user to close apps.
196 * bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
197 * system flushes all caches to disk and clears
198 * the screen
199 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
200 * code.
202 * RETURNS
203 * Success: TRUE
204 * Failure: FALSE
206 * NOTES
207 * if lpMachineName is NULL, the local computer is shutdown.
209 BOOL WINAPI InitiateSystemShutdownExA( LPSTR lpMachineName, LPSTR lpMessage,
210 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
211 DWORD dwReason)
213 FIXME("%s %s %ld %d %d %ld\n", debugstr_a(lpMachineName),
214 debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
215 bRebootAfterShutdown, dwReason);
216 return TRUE;
219 /******************************************************************************
220 * InitiateSystemShutdownExW [ADVAPI32.@]
222 * see InitiateSystemShutdownExA
224 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
225 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
226 DWORD dwReason)
228 FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName),
229 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
230 bRebootAfterShutdown, dwReason);
231 return TRUE;
234 BOOL WINAPI InitiateSystemShutdownA( LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout,
235 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
237 return InitiateSystemShutdownExA( lpMachineName, lpMessage, dwTimeout,
238 bForceAppsClosed, bRebootAfterShutdown,
239 SHTDN_REASON_MAJOR_LEGACY_API );
242 BOOL WINAPI InitiateSystemShutdownW( LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout,
243 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
245 return InitiateSystemShutdownExW( lpMachineName, lpMessage, dwTimeout,
246 bForceAppsClosed, bRebootAfterShutdown,
247 SHTDN_REASON_MAJOR_LEGACY_API );
250 BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword,
251 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
253 FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_a(lpszUsername),
254 debugstr_a(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
256 return TRUE;
259 BOOL WINAPI LogonUserW( LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword,
260 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
262 FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_w(lpszUsername),
263 debugstr_w(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
265 return TRUE;
268 DWORD WINAPI CommandLineFromMsiDescriptor(WCHAR *Descriptor, WCHAR *CommandLine,
269 DWORD *CommandLineLength)
271 FIXME("stub (%s)\n", debugstr_w(Descriptor));
272 return ERROR_CALL_NOT_IMPLEMENTED;