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
33 #include "wine/library.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
38 /******************************************************************************
39 * GetUserNameA [ADVAPI32.@]
41 * Get the current user name.
44 * lpszName [O] Destination for the user name.
45 * lpSize [I/O] Size of lpszName.
48 * Success: The length of the user name, including terminating NUL.
49 * Failure: ERROR_MORE_DATA if *lpSize is too small.
52 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
56 DWORD sizeW = *lpSize * 2;
58 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, sizeW * sizeof(WCHAR) )))
60 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
63 ret = GetUserNameW( buffer, &sizeW );
66 if (!(*lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpszName, *lpSize, NULL, NULL )))
68 *lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
69 SetLastError( ERROR_MORE_DATA );
73 else *lpSize = sizeW * 2;
74 HeapFree( GetProcessHeap(), 0, buffer );
78 /******************************************************************************
79 * GetUserNameW [ADVAPI32.@]
84 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
86 const char *name = wine_get_user_name();
87 DWORD i, len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 );
91 SetLastError(ERROR_MORE_DATA);
97 MultiByteToWideChar( CP_UNIXCP, 0, name, -1, lpszName, len );
99 /* Word uses the user name to create named mutexes and file mappings,
100 * and backslashes in the name cause the creation to fail.
102 for (i = 0; lpszName[i]; i++)
103 if (lpszName[i] == '\\' || lpszName[i] == '/') lpszName[i] = '_';
107 /******************************************************************************
108 * GetCurrentHwProfileA [ADVAPI32.@]
110 * Get the current hardware profile.
113 * pInfo [O] Destination for hardware profile information.
116 * Success: TRUE. pInfo is updated with the hardware profile details.
119 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
121 FIXME("(%p) semi-stub\n", pInfo);
122 pInfo->dwDockInfo = DOCKINFO_DOCKED;
123 strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-123456789012}");
124 strcpy(pInfo->szHwProfileName,"Wine Profile");
128 /******************************************************************************
129 * GetCurrentHwProfileW [ADVAPI32.@]
131 * See GetCurrentHwProfileA.
133 BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
135 FIXME("(%p)\n", pInfo);
140 /**************************************************************************
141 * IsTextUnicode (ADVAPI32.@)
143 * Attempt to guess whether a text buffer is Unicode.
146 * buf [I] Text buffer to test
147 * len [I] Length of buf
148 * flags [O] Destination for test results
151 * TRUE if the buffer is likely Unicode, FALSE otherwise.
153 BOOL WINAPI IsTextUnicode( LPCVOID buf, INT len, LPINT flags )
155 return RtlIsTextUnicode( buf, len, flags );
159 /******************************************************************************
160 * AbortSystemShutdownA [ADVAPI32.@]
162 * Stop a system shutdown if one is in progress.
165 * lpMachineName [I] Name of machine to not shutdown.
172 * The Wine implementation of this function is a harmless stub.
174 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
176 TRACE("stub %s (harmless)\n", lpMachineName);
180 /******************************************************************************
181 * AbortSystemShutdownW [ADVAPI32.@]
183 * See AbortSystemShutdownA.
185 BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
187 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
191 /******************************************************************************
192 * InitiateSystemShutdownExA [ADVAPI32.@]
194 * Initiate a shutdown or optionally restart the computer.
197 * lpMachineName [I] Network name of machine to shutdown.
198 * lpMessage [I] Message displayed in shutdown dialog box.
199 * dwTimeout [I] Number of seconds dialog is displayed before shutdown.
200 * bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
201 * displayed requesting user to close apps.
202 * bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
203 * system flushes all caches to disk and clears
205 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
213 * if lpMachineName is NULL, the local computer is shutdown.
215 BOOL WINAPI InitiateSystemShutdownExA( LPSTR lpMachineName, LPSTR lpMessage,
216 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
219 FIXME("%s %s %d %d %d %d\n", debugstr_a(lpMachineName),
220 debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
221 bRebootAfterShutdown, dwReason);
225 /******************************************************************************
226 * InitiateSystemShutdownExW [ADVAPI32.@]
228 * See InitiateSystemShutdownExA.
230 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
231 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
234 FIXME("%s %s %d %d %d %d\n", debugstr_w(lpMachineName),
235 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
236 bRebootAfterShutdown, dwReason);
240 BOOL WINAPI InitiateSystemShutdownA( LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout,
241 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
243 return InitiateSystemShutdownExA( lpMachineName, lpMessage, dwTimeout,
244 bForceAppsClosed, bRebootAfterShutdown,
245 SHTDN_REASON_MAJOR_LEGACY_API );
248 BOOL WINAPI InitiateSystemShutdownW( LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout,
249 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
251 return InitiateSystemShutdownExW( lpMachineName, lpMessage, dwTimeout,
252 bForceAppsClosed, bRebootAfterShutdown,
253 SHTDN_REASON_MAJOR_LEGACY_API );
256 BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword,
257 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
259 FIXME("%s %s %p 0x%08x 0x%08x %p - stub\n", debugstr_a(lpszUsername),
260 debugstr_a(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
265 BOOL WINAPI LogonUserW( LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword,
266 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
268 FIXME("%s %s %p 0x%08x 0x%08x %p - stub\n", debugstr_w(lpszUsername),
269 debugstr_w(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
274 typedef UINT (WINAPI *fnMsiProvideComponentFromDescriptor)(LPCWSTR,LPWSTR,DWORD*,DWORD*);
276 DWORD WINAPI CommandLineFromMsiDescriptor( WCHAR *szDescriptor,
277 WCHAR *szCommandLine, DWORD *pcchCommandLine )
279 static const WCHAR szMsi[] = { 'm','s','i',0 };
280 fnMsiProvideComponentFromDescriptor mpcfd;
282 UINT r = ERROR_CALL_NOT_IMPLEMENTED;
284 TRACE("%s %p %p\n", debugstr_w(szDescriptor), szCommandLine, pcchCommandLine);
286 hmsi = LoadLibraryW( szMsi );
289 mpcfd = (void*) GetProcAddress( hmsi, "MsiProvideComponentFromDescriptorW" );
291 r = mpcfd( szDescriptor, szCommandLine, pcchCommandLine, NULL );