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
22 #include "wine/port.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.
47 * lpszName [O] Destination for the user name.
48 * lpSize [I/O] Size of lpszName.
51 * Success: The length of the user name, including terminating NUL.
52 * Failure: ERROR_MORE_DATA if *lpSize is too small.
55 GetUserNameA( LPSTR lpszName
, LPDWORD lpSize
)
59 DWORD sizeW
= *lpSize
* 2;
61 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, sizeW
* sizeof(WCHAR
) )))
63 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
66 ret
= GetUserNameW( buffer
, &sizeW
);
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
);
76 else *lpSize
= sizeW
* 2;
77 HeapFree( GetProcessHeap(), 0, buffer
);
81 /******************************************************************************
82 * GetUserNameW [ADVAPI32.@]
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 );
94 SetLastError(ERROR_MORE_DATA
);
100 MultiByteToWideChar( CP_UNIXCP
, 0, name
, -1, lpszName
, len
);
104 /******************************************************************************
105 * GetCurrentHwProfileA [ADVAPI32.@]
107 * Get the current hardware profile.
110 * pInfo [O] Destination for hardware profile information.
113 * Success: TRUE. pInfo is updated with the hardware profile details.
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");
125 /******************************************************************************
126 * GetCurrentHwProfileW [ADVAPI32.@]
128 * See GetCurrentHwProfileA.
130 BOOL WINAPI
GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo
)
132 FIXME("(%p)\n", pInfo
);
137 /**************************************************************************
138 * IsTextUnicode (ADVAPI32.@)
140 * Attempt to guess whether a text buffer is Unicode.
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.
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 %ld %d %d %ld\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 %ld %d %d %ld\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%08lx 0x%08lx %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%08lx 0x%08lx %p - stub\n", debugstr_w(lpszUsername
),
263 debugstr_w(lpszDomain
), lpszPassword
, dwLogonType
, dwLogonProvider
, phToken
);
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
;