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
35 #include "wine/debug.h"
37 #include "advapi32_misc.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
41 /******************************************************************************
42 * GetUserNameA [ADVAPI32.@]
44 BOOL WINAPI
GetUserNameA( LPSTR name
, LPDWORD size
)
46 DWORD len
= GetEnvironmentVariableA( "WINEUSERNAME", name
, *size
);
49 if (!len
) return FALSE
;
50 if ((ret
= (len
< *size
))) len
++;
51 else SetLastError( ERROR_INSUFFICIENT_BUFFER
);
56 /******************************************************************************
57 * GetUserNameW [ADVAPI32.@]
59 BOOL WINAPI
GetUserNameW( LPWSTR name
, LPDWORD size
)
61 DWORD len
= GetEnvironmentVariableW( L
"WINEUSERNAME", name
, *size
);
64 if (!len
) return FALSE
;
65 if ((ret
= (len
< *size
))) len
++;
66 else SetLastError( ERROR_INSUFFICIENT_BUFFER
);
71 /******************************************************************************
72 * GetCurrentHwProfileA [ADVAPI32.@]
74 * Get the current hardware profile.
77 * pInfo [O] Destination for hardware profile information.
80 * Success: TRUE. pInfo is updated with the hardware profile details.
83 BOOL WINAPI
GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo
)
85 FIXME("(%p) semi-stub\n", pInfo
);
86 pInfo
->dwDockInfo
= DOCKINFO_DOCKED
;
87 strcpy(pInfo
->szHwProfileGuid
,"{12340001-1234-1234-1234-123456789012}");
88 strcpy(pInfo
->szHwProfileName
,"Wine Profile");
92 /******************************************************************************
93 * GetCurrentHwProfileW [ADVAPI32.@]
95 * See GetCurrentHwProfileA.
97 BOOL WINAPI
GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo
)
99 FIXME("(%p)\n", pInfo
);
104 /**************************************************************************
105 * IsTextUnicode (ADVAPI32.@)
107 * Attempt to guess whether a text buffer is Unicode.
110 * buf [I] Text buffer to test
111 * len [I] Length of buf
112 * flags [O] Destination for test results
115 * TRUE if the buffer is likely Unicode, FALSE otherwise.
117 BOOL WINAPI
IsTextUnicode( LPCVOID buf
, INT len
, LPINT flags
)
119 return RtlIsTextUnicode( buf
, len
, flags
);
123 /******************************************************************************
124 * AbortSystemShutdownA [ADVAPI32.@]
126 * Stop a system shutdown if one is in progress.
129 * lpMachineName [I] Name of machine to not shutdown.
136 * The Wine implementation of this function is a harmless stub.
138 BOOL WINAPI
AbortSystemShutdownA( LPSTR lpMachineName
)
140 TRACE("stub %s (harmless)\n", debugstr_a(lpMachineName
));
144 /******************************************************************************
145 * AbortSystemShutdownW [ADVAPI32.@]
147 * See AbortSystemShutdownA.
149 BOOL WINAPI
AbortSystemShutdownW( LPWSTR lpMachineName
)
151 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName
));
155 /******************************************************************************
156 * InitiateSystemShutdownExA [ADVAPI32.@]
158 * Initiate a shutdown or optionally restart the computer.
161 * lpMachineName [I] Network name of machine to shutdown.
162 * lpMessage [I] Message displayed in shutdown dialog box.
163 * dwTimeout [I] Number of seconds dialog is displayed before shutdown.
164 * bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
165 * displayed requesting user to close apps.
166 * bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
167 * system flushes all caches to disk and clears
169 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
177 * if lpMachineName is NULL, the local computer is shutdown.
179 BOOL WINAPI
InitiateSystemShutdownExA( LPSTR lpMachineName
, LPSTR lpMessage
,
180 DWORD dwTimeout
, BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
,
183 FIXME("%s %s %d %d %d %#x\n", debugstr_a(lpMachineName
),
184 debugstr_a(lpMessage
), dwTimeout
, bForceAppsClosed
,
185 bRebootAfterShutdown
, dwReason
);
189 /******************************************************************************
190 * InitiateSystemShutdownExW [ADVAPI32.@]
192 * See InitiateSystemShutdownExA.
194 BOOL WINAPI
InitiateSystemShutdownExW( LPWSTR lpMachineName
, LPWSTR lpMessage
,
195 DWORD dwTimeout
, BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
,
198 FIXME("%s %s %d %d %d %#x\n", debugstr_w(lpMachineName
),
199 debugstr_w(lpMessage
), dwTimeout
, bForceAppsClosed
,
200 bRebootAfterShutdown
, dwReason
);
204 BOOL WINAPI
InitiateSystemShutdownA( LPSTR lpMachineName
, LPSTR lpMessage
, DWORD dwTimeout
,
205 BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
)
207 return InitiateSystemShutdownExA( lpMachineName
, lpMessage
, dwTimeout
,
208 bForceAppsClosed
, bRebootAfterShutdown
,
209 SHTDN_REASON_MAJOR_LEGACY_API
);
212 BOOL WINAPI
InitiateSystemShutdownW( LPWSTR lpMachineName
, LPWSTR lpMessage
, DWORD dwTimeout
,
213 BOOL bForceAppsClosed
, BOOL bRebootAfterShutdown
)
215 return InitiateSystemShutdownExW( lpMachineName
, lpMessage
, dwTimeout
,
216 bForceAppsClosed
, bRebootAfterShutdown
,
217 SHTDN_REASON_MAJOR_LEGACY_API
);
220 /***********************************************************************
221 * InitiateShutdownA [ADVAPI32.@]
223 DWORD WINAPI
InitiateShutdownA(char *name
, char *message
, DWORD seconds
, DWORD flags
, DWORD reason
)
225 FIXME("%s, %s, %d, %d, %d stub\n", debugstr_a(name
), debugstr_a(message
), seconds
, flags
, reason
);
226 return ERROR_CALL_NOT_IMPLEMENTED
;
229 /***********************************************************************
230 * InitiateShutdownW [ADVAPI32.@]
232 DWORD WINAPI
InitiateShutdownW(WCHAR
*name
, WCHAR
*message
, DWORD seconds
, DWORD flags
, DWORD reason
)
234 FIXME("%s, %s, %d, %d, %d stub\n", debugstr_w(name
), debugstr_w(message
), seconds
, flags
, reason
);
235 return ERROR_CALL_NOT_IMPLEMENTED
;
238 BOOL WINAPI
LogonUserA( LPCSTR lpszUsername
, LPCSTR lpszDomain
, LPCSTR lpszPassword
,
239 DWORD dwLogonType
, DWORD dwLogonProvider
, PHANDLE phToken
)
241 WCHAR
*usernameW
= NULL
, *domainW
= NULL
, *passwordW
= NULL
;
244 TRACE("%s %s %p 0x%08x 0x%08x %p\n", debugstr_a(lpszUsername
),
245 debugstr_a(lpszDomain
), lpszPassword
, dwLogonType
, dwLogonProvider
, phToken
);
247 if (lpszUsername
&& !(usernameW
= strdupAW( lpszUsername
))) return FALSE
;
248 if (lpszDomain
&& !(domainW
= strdupAW( lpszUsername
))) goto done
;
249 if (lpszPassword
&& !(passwordW
= strdupAW( lpszPassword
))) goto done
;
251 ret
= LogonUserW( usernameW
, domainW
, passwordW
, dwLogonType
, dwLogonProvider
, phToken
);
254 heap_free( usernameW
);
255 heap_free( domainW
);
256 heap_free( passwordW
);
260 BOOL WINAPI
LogonUserW( LPCWSTR lpszUsername
, LPCWSTR lpszDomain
, LPCWSTR lpszPassword
,
261 DWORD dwLogonType
, DWORD dwLogonProvider
, PHANDLE phToken
)
263 FIXME("%s %s %p 0x%08x 0x%08x %p - stub\n", debugstr_w(lpszUsername
),
264 debugstr_w(lpszDomain
), lpszPassword
, dwLogonType
, dwLogonProvider
, phToken
);
266 *phToken
= (HANDLE
*)0xdeadbeef;
270 typedef UINT (WINAPI
*fnMsiProvideComponentFromDescriptor
)(LPCWSTR
,LPWSTR
,DWORD
*,DWORD
*);
272 DWORD WINAPI
CommandLineFromMsiDescriptor( WCHAR
*szDescriptor
,
273 WCHAR
*szCommandLine
, DWORD
*pcchCommandLine
)
275 fnMsiProvideComponentFromDescriptor mpcfd
;
277 UINT r
= ERROR_CALL_NOT_IMPLEMENTED
;
279 TRACE("%s %p %p\n", debugstr_w(szDescriptor
), szCommandLine
, pcchCommandLine
);
281 hmsi
= LoadLibraryW( L
"msi" );
284 mpcfd
= (fnMsiProvideComponentFromDescriptor
)GetProcAddress( hmsi
,
285 "MsiProvideComponentFromDescriptorW" );
287 r
= mpcfd( szDescriptor
, szCommandLine
, pcchCommandLine
, NULL
);
292 /***********************************************************************
293 * RegisterWaitChainCOMCallback (ole32.@)
295 void WINAPI
RegisterWaitChainCOMCallback(PCOGETCALLSTATE call_state_cb
,
296 PCOGETACTIVATIONSTATE activation_state_cb
)
298 FIXME("%p, %p\n", call_state_cb
, activation_state_cb
);