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 len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 );
91 SetLastError(ERROR_MORE_DATA);
97 MultiByteToWideChar( CP_UNIXCP, 0, name, -1, lpszName, len );
101 /******************************************************************************
102 * GetCurrentHwProfileA [ADVAPI32.@]
104 * Get the current hardware profile.
107 * pInfo [O] Destination for hardware profile information.
110 * Success: TRUE. pInfo is updated with the hardware profile details.
113 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
115 FIXME("(%p) semi-stub\n", pInfo);
116 pInfo->dwDockInfo = DOCKINFO_DOCKED;
117 strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
118 strcpy(pInfo->szHwProfileName,"Wine Profile");
122 /******************************************************************************
123 * GetCurrentHwProfileW [ADVAPI32.@]
125 * See GetCurrentHwProfileA.
127 BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
129 FIXME("(%p)\n", pInfo);
134 /**************************************************************************
135 * IsTextUnicode (ADVAPI32.@)
137 * Attempt to guess whether a text buffer is Unicode.
140 * buf [I] Text buffer to test
141 * len [I] Length of buf
142 * flags [O] Destination for test results
145 * TRUE if the buffer is likely Unicode, FALSE otherwise.
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.
159 * lpMachineName [I] Name of machine to not shutdown.
166 * The Wine implementation of this function is a harmless stub.
168 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
170 TRACE("stub %s (harmless)\n", lpMachineName);
174 /******************************************************************************
175 * AbortSystemShutdownW [ADVAPI32.@]
177 * See AbortSystemShutdownA.
179 BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
181 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
185 /******************************************************************************
186 * InitiateSystemShutdownExA [ADVAPI32.@]
188 * Initiate a shutdown or optionally restart the computer.
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
199 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
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,
213 FIXME("%s %s %d %d %d %d\n", debugstr_a(lpMachineName),
214 debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
215 bRebootAfterShutdown, dwReason);
219 /******************************************************************************
220 * InitiateSystemShutdownExW [ADVAPI32.@]
222 * See InitiateSystemShutdownExA.
224 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
225 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
228 FIXME("%s %s %d %d %d %d\n", debugstr_w(lpMachineName),
229 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
230 bRebootAfterShutdown, dwReason);
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%08x 0x%08x %p - stub\n", debugstr_a(lpszUsername),
254 debugstr_a(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
259 BOOL WINAPI LogonUserW( LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword,
260 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
262 FIXME("%s %s %p 0x%08x 0x%08x %p - stub\n", debugstr_w(lpszUsername),
263 debugstr_w(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
268 typedef UINT (WINAPI *fnMsiProvideComponentFromDescriptor)(LPCWSTR,LPWSTR,DWORD*,DWORD*);
270 DWORD WINAPI CommandLineFromMsiDescriptor( WCHAR *szDescriptor,
271 WCHAR *szCommandLine, DWORD *pcchCommandLine )
273 static const WCHAR szMsi[] = { 'm','s','i',0 };
274 fnMsiProvideComponentFromDescriptor mpcfd;
276 UINT r = ERROR_CALL_NOT_IMPLEMENTED;
278 TRACE("%s %p %p\n", debugstr_w(szDescriptor), szCommandLine, pcchCommandLine);
280 hmsi = LoadLibraryW( szMsi );
283 mpcfd = (void*) GetProcAddress( hmsi, "MsiProvideComponentFromDescriptorW" );
285 r = mpcfd( szDescriptor, szCommandLine, pcchCommandLine, NULL );