advapi32/tests: Expand tests for performance keys.
[wine.git] / dlls / advapi32 / advapi.c
blob33c63f3cb20bc62d2d9ff7f77a6b1e894c2d25fb
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <errno.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnls.h"
29 #include "winreg.h"
30 #include "winternl.h"
31 #include "winerror.h"
32 #include "wincred.h"
33 #include "wct.h"
35 #include "wine/debug.h"
37 #include "advapi32_misc.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
41 /******************************************************************************
42 * GetUserNameA [ADVAPI32.@]
44 BOOL WINAPI GetUserNameA( LPSTR name, LPDWORD size )
46 DWORD len = GetEnvironmentVariableA( "WINEUSERNAME", name, *size );
47 BOOL ret;
49 if (!len) return FALSE;
50 if ((ret = (len < *size))) len++;
51 else SetLastError( ERROR_INSUFFICIENT_BUFFER );
52 *size = len;
53 return ret;
56 /******************************************************************************
57 * GetUserNameW [ADVAPI32.@]
59 BOOL WINAPI GetUserNameW( LPWSTR name, LPDWORD size )
61 DWORD len = GetEnvironmentVariableW( L"WINEUSERNAME", name, *size );
62 BOOL ret;
64 if (!len) return FALSE;
65 if ((ret = (len < *size))) len++;
66 else SetLastError( ERROR_INSUFFICIENT_BUFFER );
67 *size = len;
68 return ret;
71 /******************************************************************************
72 * GetCurrentHwProfileA [ADVAPI32.@]
74 * Get the current hardware profile.
76 * PARAMS
77 * pInfo [O] Destination for hardware profile information.
79 * RETURNS
80 * Success: TRUE. pInfo is updated with the hardware profile details.
81 * Failure: FALSE.
83 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
85 FIXME("(%p) semi-stub\n", pInfo);
86 pInfo->dwDockInfo = DOCKINFO_DOCKED;
87 strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-123456789012}");
88 strcpy(pInfo->szHwProfileName,"Wine Profile");
89 return TRUE;
92 /******************************************************************************
93 * GetCurrentHwProfileW [ADVAPI32.@]
95 * See GetCurrentHwProfileA.
97 BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
99 FIXME("(%p)\n", pInfo);
100 return FALSE;
104 /**************************************************************************
105 * IsTextUnicode (ADVAPI32.@)
107 * Attempt to guess whether a text buffer is Unicode.
109 * PARAMS
110 * buf [I] Text buffer to test
111 * len [I] Length of buf
112 * flags [O] Destination for test results
114 * RETURNS
115 * TRUE if the buffer is likely Unicode, FALSE otherwise.
117 BOOL WINAPI IsTextUnicode( LPCVOID buf, INT len, LPINT flags )
119 return RtlIsTextUnicode( buf, len, flags );
123 /******************************************************************************
124 * AbortSystemShutdownA [ADVAPI32.@]
126 * Stop a system shutdown if one is in progress.
128 * PARAMS
129 * lpMachineName [I] Name of machine to not shutdown.
131 * RETURNS
132 * Success: TRUE.
133 * Failure: FALSE.
135 * NOTES
136 * The Wine implementation of this function is a harmless stub.
138 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
140 TRACE("stub %s (harmless)\n", debugstr_a(lpMachineName));
141 return TRUE;
144 /******************************************************************************
145 * AbortSystemShutdownW [ADVAPI32.@]
147 * See AbortSystemShutdownA.
149 BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
151 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
152 return TRUE;
155 /******************************************************************************
156 * InitiateSystemShutdownExA [ADVAPI32.@]
158 * Initiate a shutdown or optionally restart the computer.
160 * PARAMS
161 * lpMachineName [I] Network name of machine to shutdown.
162 * lpMessage [I] Message displayed in shutdown dialog box.
163 * dwTimeout [I] Number of seconds dialog is displayed before shutdown.
164 * bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
165 * displayed requesting user to close apps.
166 * bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
167 * system flushes all caches to disk and clears
168 * the screen
169 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
170 * code.
172 * RETURNS
173 * Success: TRUE
174 * Failure: FALSE
176 * NOTES
177 * if lpMachineName is NULL, the local computer is shutdown.
179 BOOL WINAPI InitiateSystemShutdownExA( LPSTR lpMachineName, LPSTR lpMessage,
180 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
181 DWORD dwReason)
183 FIXME("%s %s %d %d %d %#x\n", debugstr_a(lpMachineName),
184 debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
185 bRebootAfterShutdown, dwReason);
186 return TRUE;
189 /******************************************************************************
190 * InitiateSystemShutdownExW [ADVAPI32.@]
192 * See InitiateSystemShutdownExA.
194 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
195 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
196 DWORD dwReason)
198 FIXME("%s %s %d %d %d %#x\n", debugstr_w(lpMachineName),
199 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
200 bRebootAfterShutdown, dwReason);
201 return TRUE;
204 BOOL WINAPI InitiateSystemShutdownA( LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout,
205 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
207 return InitiateSystemShutdownExA( lpMachineName, lpMessage, dwTimeout,
208 bForceAppsClosed, bRebootAfterShutdown,
209 SHTDN_REASON_MAJOR_LEGACY_API );
212 BOOL WINAPI InitiateSystemShutdownW( LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout,
213 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
215 return InitiateSystemShutdownExW( lpMachineName, lpMessage, dwTimeout,
216 bForceAppsClosed, bRebootAfterShutdown,
217 SHTDN_REASON_MAJOR_LEGACY_API );
220 /***********************************************************************
221 * InitiateShutdownA [ADVAPI32.@]
223 DWORD WINAPI InitiateShutdownA(char *name, char *message, DWORD seconds, DWORD flags, DWORD reason)
225 FIXME("%s, %s, %d, %d, %d stub\n", debugstr_a(name), debugstr_a(message), seconds, flags, reason);
226 return ERROR_CALL_NOT_IMPLEMENTED;
229 /***********************************************************************
230 * InitiateShutdownW [ADVAPI32.@]
232 DWORD WINAPI InitiateShutdownW(WCHAR *name, WCHAR *message, DWORD seconds, DWORD flags, DWORD reason)
234 FIXME("%s, %s, %d, %d, %d stub\n", debugstr_w(name), debugstr_w(message), seconds, flags, reason);
235 return ERROR_CALL_NOT_IMPLEMENTED;
238 BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword,
239 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
241 WCHAR *usernameW = NULL, *domainW = NULL, *passwordW = NULL;
242 BOOL ret = FALSE;
244 TRACE("%s %s %p 0x%08x 0x%08x %p\n", debugstr_a(lpszUsername),
245 debugstr_a(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
247 if (lpszUsername && !(usernameW = strdupAW( lpszUsername ))) return FALSE;
248 if (lpszDomain && !(domainW = strdupAW( lpszUsername ))) goto done;
249 if (lpszPassword && !(passwordW = strdupAW( lpszPassword ))) goto done;
251 ret = LogonUserW( usernameW, domainW, passwordW, dwLogonType, dwLogonProvider, phToken );
253 done:
254 heap_free( usernameW );
255 heap_free( domainW );
256 heap_free( passwordW );
257 return ret;
260 BOOL WINAPI LogonUserW( LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword,
261 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
263 FIXME("%s %s %p 0x%08x 0x%08x %p - stub\n", debugstr_w(lpszUsername),
264 debugstr_w(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
266 *phToken = (HANDLE *)0xdeadbeef;
267 return TRUE;
270 typedef UINT (WINAPI *fnMsiProvideComponentFromDescriptor)(LPCWSTR,LPWSTR,DWORD*,DWORD*);
272 DWORD WINAPI CommandLineFromMsiDescriptor( WCHAR *szDescriptor,
273 WCHAR *szCommandLine, DWORD *pcchCommandLine )
275 fnMsiProvideComponentFromDescriptor mpcfd;
276 HMODULE hmsi;
277 UINT r = ERROR_CALL_NOT_IMPLEMENTED;
279 TRACE("%s %p %p\n", debugstr_w(szDescriptor), szCommandLine, pcchCommandLine);
281 hmsi = LoadLibraryW( L"msi" );
282 if (!hmsi)
283 return r;
284 mpcfd = (fnMsiProvideComponentFromDescriptor)GetProcAddress( hmsi,
285 "MsiProvideComponentFromDescriptorW" );
286 if (mpcfd)
287 r = mpcfd( szDescriptor, szCommandLine, pcchCommandLine, NULL );
288 FreeLibrary( hmsi );
289 return r;
292 /***********************************************************************
293 * RegisterWaitChainCOMCallback (ole32.@)
295 void WINAPI RegisterWaitChainCOMCallback(PCOGETCALLSTATE call_state_cb,
296 PCOGETACTIVATIONSTATE activation_state_cb)
298 FIXME("%p, %p\n", call_state_cb, activation_state_cb);