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
34 #include "wine/library.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
39 /******************************************************************************
40 * GetUserNameA [ADVAPI32.@]
42 * Get the current user name.
45 * lpszName [O] Destination for the user name.
46 * lpSize [I/O] Size of lpszName.
49 * Success: The length of the user name, including terminating NUL.
50 * Failure: ERROR_MORE_DATA if *lpSize is too small.
53 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
57 DWORD sizeW = *lpSize * 2;
59 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, sizeW * sizeof(WCHAR) )))
61 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
64 ret = GetUserNameW( buffer, &sizeW );
67 if (!(*lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpszName, *lpSize, NULL, NULL )))
69 *lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
70 SetLastError( ERROR_MORE_DATA );
74 else *lpSize = sizeW * 2;
75 HeapFree( GetProcessHeap(), 0, buffer );
79 /******************************************************************************
80 * GetUserNameW [ADVAPI32.@]
85 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
87 const char *name = wine_get_user_name();
88 DWORD i, len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 );
92 SetLastError(ERROR_MORE_DATA);
98 MultiByteToWideChar( CP_UNIXCP, 0, name, -1, lpszName, len );
100 /* Word uses the user name to create named mutexes and file mappings,
101 * and backslashes in the name cause the creation to fail.
103 for (i = 0; lpszName[i]; i++)
104 if (lpszName[i] == '\\' || lpszName[i] == '/') lpszName[i] = '_';
108 /******************************************************************************
109 * GetCurrentHwProfileA [ADVAPI32.@]
111 * Get the current hardware profile.
114 * pInfo [O] Destination for hardware profile information.
117 * Success: TRUE. pInfo is updated with the hardware profile details.
120 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
122 FIXME("(%p) semi-stub\n", pInfo);
123 pInfo->dwDockInfo = DOCKINFO_DOCKED;
124 strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-123456789012}");
125 strcpy(pInfo->szHwProfileName,"Wine Profile");
129 /******************************************************************************
130 * GetCurrentHwProfileW [ADVAPI32.@]
132 * See GetCurrentHwProfileA.
134 BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
136 FIXME("(%p)\n", pInfo);
141 /**************************************************************************
142 * IsTextUnicode (ADVAPI32.@)
144 * Attempt to guess whether a text buffer is Unicode.
147 * buf [I] Text buffer to test
148 * len [I] Length of buf
149 * flags [O] Destination for test results
152 * TRUE if the buffer is likely Unicode, FALSE otherwise.
154 BOOL WINAPI IsTextUnicode( LPCVOID buf, INT len, LPINT flags )
156 return RtlIsTextUnicode( buf, len, flags );
160 /******************************************************************************
161 * AbortSystemShutdownA [ADVAPI32.@]
163 * Stop a system shutdown if one is in progress.
166 * lpMachineName [I] Name of machine to not shutdown.
173 * The Wine implementation of this function is a harmless stub.
175 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
177 TRACE("stub %s (harmless)\n", lpMachineName);
181 /******************************************************************************
182 * AbortSystemShutdownW [ADVAPI32.@]
184 * See AbortSystemShutdownA.
186 BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
188 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
192 /******************************************************************************
193 * InitiateSystemShutdownExA [ADVAPI32.@]
195 * Initiate a shutdown or optionally restart the computer.
198 * lpMachineName [I] Network name of machine to shutdown.
199 * lpMessage [I] Message displayed in shutdown dialog box.
200 * dwTimeout [I] Number of seconds dialog is displayed before shutdown.
201 * bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
202 * displayed requesting user to close apps.
203 * bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
204 * system flushes all caches to disk and clears
206 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
214 * if lpMachineName is NULL, the local computer is shutdown.
216 BOOL WINAPI InitiateSystemShutdownExA( LPSTR lpMachineName, LPSTR lpMessage,
217 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
220 FIXME("%s %s %d %d %d %d\n", debugstr_a(lpMachineName),
221 debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
222 bRebootAfterShutdown, dwReason);
226 /******************************************************************************
227 * InitiateSystemShutdownExW [ADVAPI32.@]
229 * See InitiateSystemShutdownExA.
231 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
232 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
235 FIXME("%s %s %d %d %d %d\n", debugstr_w(lpMachineName),
236 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
237 bRebootAfterShutdown, dwReason);
241 BOOL WINAPI InitiateSystemShutdownA( LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout,
242 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
244 return InitiateSystemShutdownExA( lpMachineName, lpMessage, dwTimeout,
245 bForceAppsClosed, bRebootAfterShutdown,
246 SHTDN_REASON_MAJOR_LEGACY_API );
249 BOOL WINAPI InitiateSystemShutdownW( LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout,
250 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
252 return InitiateSystemShutdownExW( lpMachineName, lpMessage, dwTimeout,
253 bForceAppsClosed, bRebootAfterShutdown,
254 SHTDN_REASON_MAJOR_LEGACY_API );
257 BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword,
258 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
260 FIXME("%s %s %p 0x%08x 0x%08x %p - stub\n", debugstr_a(lpszUsername),
261 debugstr_a(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
266 BOOL WINAPI LogonUserW( LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword,
267 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
269 FIXME("%s %s %p 0x%08x 0x%08x %p - stub\n", debugstr_w(lpszUsername),
270 debugstr_w(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
275 typedef UINT (WINAPI *fnMsiProvideComponentFromDescriptor)(LPCWSTR,LPWSTR,DWORD*,DWORD*);
277 DWORD WINAPI CommandLineFromMsiDescriptor( WCHAR *szDescriptor,
278 WCHAR *szCommandLine, DWORD *pcchCommandLine )
280 static const WCHAR szMsi[] = { 'm','s','i',0 };
281 fnMsiProvideComponentFromDescriptor mpcfd;
283 UINT r = ERROR_CALL_NOT_IMPLEMENTED;
285 TRACE("%s %p %p\n", debugstr_w(szDescriptor), szCommandLine, pcchCommandLine);
287 hmsi = LoadLibraryW( szMsi );
290 mpcfd = (fnMsiProvideComponentFromDescriptor)GetProcAddress( hmsi,
291 "MsiProvideComponentFromDescriptorW" );
293 r = mpcfd( szDescriptor, szCommandLine, pcchCommandLine, NULL );