mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 04:45:45 +00:00
[USERINIT]
- Move code for playing logon sound to winlogon where it should belong [WINLOGON] - Create a thread for playing the logon sound - Query the status of sysaudio. If sysaudio isnt running yet, wait a second. - Wait for max 20 seconds to get sysaudio running - Finally logon sound should work svn path=/trunk/; revision=42051
This commit is contained in:
parent
dac78ab19a
commit
2b9d1b809c
2 changed files with 96 additions and 46 deletions
|
@ -447,51 +447,6 @@ VOID SetUserWallpaper(VOID)
|
||||||
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
|
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
|
||||||
PlayLogonSound()
|
|
||||||
{
|
|
||||||
HKEY hKey;
|
|
||||||
WCHAR szBuffer[MAX_PATH] = {0};
|
|
||||||
WCHAR szDest[MAX_PATH];
|
|
||||||
DWORD dwSize = sizeof(szBuffer);
|
|
||||||
HMODULE hLibrary;
|
|
||||||
typedef BOOL WINAPI (*PLAYSOUNDW)(LPCWSTR,HMODULE,DWORD);
|
|
||||||
PLAYSOUNDW Play;
|
|
||||||
|
|
||||||
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"AppEvents\\Schemes\\Apps\\.Default\\WindowsLogon\\.Current", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)szBuffer, &dwSize) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
if (!szBuffer[0])
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
szBuffer[MAX_PATH-1] = L'\0';
|
|
||||||
if (ExpandEnvironmentStringsW(szBuffer, szDest, MAX_PATH))
|
|
||||||
{
|
|
||||||
hLibrary = LoadLibraryW(L"winmm.dll");
|
|
||||||
if (hLibrary)
|
|
||||||
{
|
|
||||||
Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
|
|
||||||
if (Play)
|
|
||||||
{
|
|
||||||
Play(szDest, NULL, SND_FILENAME);
|
|
||||||
}
|
|
||||||
FreeLibrary(hLibrary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID SetUserSettings(VOID)
|
VOID SetUserSettings(VOID)
|
||||||
{
|
{
|
||||||
|
@ -540,7 +495,6 @@ wWinMain(IN HINSTANCE hInst,
|
||||||
SetUserSettings();
|
SetUserSettings();
|
||||||
StartShell();
|
StartShell();
|
||||||
NotifyLogon();
|
NotifyLogon();
|
||||||
PlayLogonSound();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,94 @@ PWLSESSION WLSession = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
WINAPI
|
||||||
|
PlayLogonSoundThread(
|
||||||
|
IN LPVOID lpParameter)
|
||||||
|
{
|
||||||
|
HKEY hKey;
|
||||||
|
WCHAR szBuffer[MAX_PATH] = {0};
|
||||||
|
WCHAR szDest[MAX_PATH];
|
||||||
|
DWORD dwSize = sizeof(szBuffer);
|
||||||
|
HMODULE hLibrary;
|
||||||
|
SERVICE_STATUS_PROCESS Info;
|
||||||
|
typedef BOOL WINAPI (*PLAYSOUNDW)(LPCWSTR,HMODULE,DWORD);
|
||||||
|
PLAYSOUNDW Play;
|
||||||
|
ULONG Index = 0;
|
||||||
|
|
||||||
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"AppEvents\\Schemes\\Apps\\.Default\\WindowsLogon\\.Current", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
ExitThread(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)szBuffer, &dwSize) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
ExitThread(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
|
if (!szBuffer[0])
|
||||||
|
ExitThread(0);
|
||||||
|
|
||||||
|
|
||||||
|
szBuffer[MAX_PATH-1] = L'\0';
|
||||||
|
if (ExpandEnvironmentStringsW(szBuffer, szDest, MAX_PATH))
|
||||||
|
{
|
||||||
|
SC_HANDLE hSCManager, hService;
|
||||||
|
|
||||||
|
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
|
||||||
|
if (!hSCManager)
|
||||||
|
ExitThread(0);;
|
||||||
|
|
||||||
|
hService = OpenServiceW(hSCManager, L"sysaudio", GENERIC_READ);
|
||||||
|
if (!hService)
|
||||||
|
{
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
TRACE("WL: failed to open sysaudio Status %x", GetLastError());
|
||||||
|
ExitThread(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!QueryServiceStatusEx(hService, SC_STATUS_PROCESS_INFO, (LPBYTE)&Info, sizeof(SERVICE_STATUS_PROCESS), &dwSize))
|
||||||
|
{
|
||||||
|
TRACE("WL: QueryServiceStatusEx failed %x\n", GetLastError());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Info.dwCurrentState == SERVICE_RUNNING)
|
||||||
|
break;
|
||||||
|
|
||||||
|
Sleep(1000);
|
||||||
|
|
||||||
|
}while(Index < 20);
|
||||||
|
|
||||||
|
CloseServiceHandle(hService);
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
|
||||||
|
if (Info.dwCurrentState != SERVICE_RUNNING)
|
||||||
|
ExitThread(0);
|
||||||
|
|
||||||
|
|
||||||
|
hLibrary = LoadLibraryW(L"winmm.dll");
|
||||||
|
if (hLibrary)
|
||||||
|
{
|
||||||
|
Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
|
||||||
|
if (Play)
|
||||||
|
{
|
||||||
|
Play(szDest, NULL, SND_FILENAME);
|
||||||
|
}
|
||||||
|
FreeLibrary(hLibrary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExitThread(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
StartServicesManager(VOID)
|
StartServicesManager(VOID)
|
||||||
{
|
{
|
||||||
|
@ -201,6 +289,7 @@ WinMain(
|
||||||
#endif
|
#endif
|
||||||
ULONG HardErrorResponse;
|
ULONG HardErrorResponse;
|
||||||
MSG Msg;
|
MSG Msg;
|
||||||
|
HANDLE hThread;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
|
@ -317,6 +406,13 @@ WinMain(
|
||||||
else
|
else
|
||||||
PostMessageW(WLSession->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_TIMEOUT, 0);
|
PostMessageW(WLSession->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_TIMEOUT, 0);
|
||||||
|
|
||||||
|
/* Play logon sound */
|
||||||
|
hThread = CreateThread(NULL, 0, PlayLogonSoundThread, NULL, 0, NULL);
|
||||||
|
if (hThread)
|
||||||
|
{
|
||||||
|
CloseHandle(hThread);
|
||||||
|
}
|
||||||
|
|
||||||
/* Tell kernel that CurrentControlSet is good (needed
|
/* Tell kernel that CurrentControlSet is good (needed
|
||||||
* to support Last good known configuration boot) */
|
* to support Last good known configuration boot) */
|
||||||
NtInitializeRegistry(CM_BOOT_FLAG_ACCEPTED);
|
NtInitializeRegistry(CM_BOOT_FLAG_ACCEPTED);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue