Author: janderwald
Date: Sun Aug 27 23:22:48 2006
New Revision: 23752
URL:
http://svn.reactos.org/svn/reactos?rev=23752&view=rev
Log:
* auto-start apps in autostart folder
* currently only works for current user
* SHGetFolderPathW CSIDL_ALTSTARTUP fails (All Users\...)
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 (original)
+++ trunk/reactos/base/system/userinit/userinit.c Sun Aug 27 23:22:48 2006
@@ -25,6 +25,7 @@
*/
#include <windows.h>
#include <cfgmgr32.h>
+#include <shlobj.h>
#include "resource.h"
#define CMP_MAGIC 0x01234567
@@ -158,6 +159,48 @@
return Ret;
}
+static VOID
+StartAutoApplications(int clsid)
+{
+ WCHAR szPath[MAX_PATH] = {0};
+ HRESULT hResult;
+ HANDLE hFind;
+ WIN32_FIND_DATAW findData;
+ SHELLEXECUTEINFOW ExecInfo;
+ size_t len;
+
+ hResult = SHGetFolderPathW(NULL, clsid, NULL, SHGFP_TYPE_CURRENT, szPath);
+ len = wcslen(szPath);
+ if (hResult == E_FAIL || hResult == E_INVALIDARG || len == 0)
+ {
+ return;
+ }
+
+ wcscat(szPath, L"\\*");
+ hFind = FindFirstFileW(szPath, &findData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ return;
+ }
+ szPath[len] = L'\0';
+
+ do
+ {
+ if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
(findData.nFileSizeHigh || findData.nFileSizeLow))
+ {
+ memset(&ExecInfo, 0x0, sizeof(SHELLEXECUTEINFOW));
+ ExecInfo.cbSize = sizeof(ExecInfo);
+ ExecInfo.lpVerb = L"open";
+ ExecInfo.lpFile = findData.cFileName;
+ ExecInfo.lpDirectory = szPath;
+ ShellExecuteExW(&ExecInfo);
+ }
+ }while(FindNextFileW(hFind, &findData));
+ FindClose(hFind);
+}
+
+
+
static
void StartShell(void)
{
@@ -186,6 +229,8 @@
&si,
&pi))
{
+ StartAutoApplications(CSIDL_STARTUP);
+ StartAutoApplications(CSIDL_ALTSTARTUP);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
@@ -250,6 +295,7 @@
}
+
#ifdef _MSC_VER
#pragma warning(disable : 4100)
#endif /* _MSC_VER */