This shouldn't be in here.
I can't tell you where it should be as I've never looked, but it's not
userinit's responsibility to play logon music.
-----Original Message-----
From: ros-diffs-bounces(a)reactos.org [mailto:ros-diffs-bounces@reactos.org] On Behalf Of
janderwald(a)svn.reactos.org
Sent: 18 May 2009 16:41
To: ros-diffs(a)reactos.org
Subject: [ros-diffs] [janderwald] 40967: - Play default logon sound when logging on - Due
to unknown issues, this only works at the 2nd login ATM
Author: janderwald
Date: Mon May 18 19:41:00 2009
New Revision: 40967
URL:
http://svn.reactos.org/svn/reactos?rev=40967&view=rev
Log:
- Play default logon sound when logging on
- Due to unknown issues, this only works at the 2nd login ATM
Modified:
trunk/reactos/base/system/userinit/userinit.c
Modified: trunk/reactos/base/system/userinit/userinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/userinit/useriā¦
==============================================================================
--- trunk/reactos/base/system/userinit/userinit.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/userinit/userinit.c [iso-8859-1] Mon May 18 19:41:00 2009
@@ -591,6 +591,51 @@
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
VOID SetUserSettings(VOID)
{
@@ -640,6 +685,7 @@
SetUserSettings();
StartShell();
NotifyLogon();
+ PlayLogonSound();
return 0;
}