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"
35 #include "wine/library.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
40 /******************************************************************************
41 * GetUserNameA [ADVAPI32.@]
43 * Get the current user name.
46 * lpszName [O] Destination for the user name.
47 * lpSize [I/O] Size of lpszName.
50 * Success: The length of the user name, including terminating NUL.
51 * Failure: ERROR_MORE_DATA if *lpSize is too small.
54 GetUserNameA( LPSTR lpszName
, LPDWORD lpSize
)
58 DWORD sizeW
= *lpSize
* 2;
60 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, sizeW
* sizeof(WCHAR
) )))
62 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
65 ret
= GetUserNameW( buffer
, &sizeW
);
68 if (!(*lpSize
= WideCharToMultiByte( CP_ACP
, 0, buffer
, -1, lpszName
, *lpSize
, NULL
, NULL
)))
70 *lpSize
= WideCharToMultiByte( CP_ACP
, 0, buffer
, -1, NULL
, 0, NULL
, NULL
);
71 SetLastError( ERROR_MORE_DATA
);
75 else *lpSize
= sizeW
* 2;
76 HeapFree( GetProcessHeap(), 0, buffer
);
80 /******************************************************************************
81 * GetUserNameW [ADVAPI32.@]
86 GetUserNameW( LPWSTR lpszName
, LPDWORD lpSize
)
88 const char *name
= wine_get_user_name();
89 DWORD len
= MultiByteToWideChar( CP_UNIXCP
, 0, name
, -1, NULL
, 0 );
93 SetLastError(ERROR_MORE_DATA
);
99 MultiByteToWideChar( CP_UNIXCP
, 0, name
, -1, lpszName
, len
);
103 /******************************************************************************
104 * GetCurrentHwProfileA [ADVAPI32.@]
106 * Get the current hardware profile.
109 * pInfo [O] Destination for hardware profile information.
112 * Success: TRUE. pInfo is updated with the hardware profile details.
115 BOOL WINAPI
GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo
)
117 FIXME("(%p) semi-stub\n", pInfo
);
118 pInfo
->dwDockInfo
= DOCKINFO_DOCKED
;
119 strcpy(pInfo
->szHwProfileGuid
,"{12340001-1234-1234-1234-1233456789012}");
120 strcpy(pInfo
->szHwProfileName
,"Wine Profile");
124 /******************************************************************************
125 * GetCurrentHwProfileW [ADVAPI32.@]
127 * See GetCurrentHwProfileA.
129 BOOL WINAPI
GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo
)
131 FIXME("(%p)\n", pInfo
);
135 /******************************************************************************
136 * AbortSystemShutdownA [ADVAPI32.@]
138 * Stop a system shutdown if one is in progress.
141 * lpMachineName [I] Name of machine to not shutdown.
148 * The Wine implementation of this function is a harmless stub.
150 BOOL WINAPI
AbortSystemShutdownA( LPSTR lpMachineName
)
152 TRACE("stub %s (harmless)\n", lpMachineName
);
156 /******************************************************************************
157 * AbortSystemShutdownW [ADVAPI32.@]
159 * See AbortSystemShutdownA.
161 BOOL WINAPI
AbortSystemShutdownW( LPWSTR lpMachineName
)
163 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName
));
167 /******************************************************************************
168 * InitiateSystemShutdownExA [ADVAPI32.@]
170 * Initiate a shutdown or optionally restart the computer.
173 * lpMachineName [I] Network name of machine to shutdown.
174 * lpMessage [I] Message displayed in shutdown dialog box.
175 * dwTimeout [I] Number of seconds dialog is displayed before shutdown.
176 * bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
177 * displayed requesting user to close apps.
178 * bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
179 * system flushes all caches to disk and clears
181 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
189 * if lpMachineName is NULL, the local computer is shutdown.
191 BOOL WINAPI
InitiateSystemShutdownExA( LPSTR lpMachineName
, LPSTR lpMessage
,
192 DWORD dwTimeout
, BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
,
195 FIXME("%s %s %ld %d %d %ld\n", debugstr_a(lpMachineName
),
196 debugstr_a(lpMessage
), dwTimeout
, bForceAppsClosed
,
197 bRebootAfterShutdown
, dwReason
);
201 /******************************************************************************
202 * InitiateSystemShutdownExW [ADVAPI32.@]
204 * see InitiateSystemShutdownExA
206 BOOL WINAPI
InitiateSystemShutdownExW( LPWSTR lpMachineName
, LPWSTR lpMessage
,
207 DWORD dwTimeout
, BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
,
210 FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName
),
211 debugstr_w(lpMessage
), dwTimeout
, bForceAppsClosed
,
212 bRebootAfterShutdown
, dwReason
);
216 BOOL WINAPI
InitiateSystemShutdownA( LPSTR lpMachineName
, LPSTR lpMessage
, DWORD dwTimeout
,
217 BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
)
219 return InitiateSystemShutdownExA( lpMachineName
, lpMessage
, dwTimeout
,
220 bForceAppsClosed
, bRebootAfterShutdown
,
221 SHTDN_REASON_MAJOR_LEGACY_API
);
224 BOOL WINAPI
InitiateSystemShutdownW( LPWSTR lpMachineName
, LPWSTR lpMessage
, DWORD dwTimeout
,
225 BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
)
227 return InitiateSystemShutdownExW( lpMachineName
, lpMessage
, dwTimeout
,
228 bForceAppsClosed
, bRebootAfterShutdown
,
229 SHTDN_REASON_MAJOR_LEGACY_API
);
232 BOOL WINAPI
LogonUserA( LPCSTR lpszUsername
, LPCSTR lpszDomain
, LPCSTR lpszPassword
,
233 DWORD dwLogonType
, DWORD dwLogonProvider
, PHANDLE phToken
)
235 FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_a(lpszUsername
),
236 debugstr_a(lpszDomain
), lpszPassword
, dwLogonType
, dwLogonProvider
, phToken
);
241 BOOL WINAPI
LogonUserW( LPCWSTR lpszUsername
, LPCWSTR lpszDomain
, LPCWSTR lpszPassword
,
242 DWORD dwLogonType
, DWORD dwLogonProvider
, PHANDLE phToken
)
244 FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_w(lpszUsername
),
245 debugstr_w(lpszDomain
), lpszPassword
, dwLogonType
, dwLogonProvider
, phToken
);
250 DWORD WINAPI
CommandLineFromMsiDescriptor(WCHAR
*Descriptor
, WCHAR
*CommandLine
,
251 DWORD
*CommandLineLength
)
253 FIXME("stub (%s)\n", debugstr_w(Descriptor
));
254 return ERROR_CALL_NOT_IMPLEMENTED
;