Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/schedsvc/atsvc.c | 41 ++++++++++++++++++++++++++++++++++++++++ dlls/schedsvc/schedsvc_private.h | 1 + dlls/schedsvc/svc_main.c | 2 ++ 3 files changed, 44 insertions(+)
diff --git a/dlls/schedsvc/atsvc.c b/dlls/schedsvc/atsvc.c index 597df34f2a..b5b8317ded 100644 --- a/dlls/schedsvc/atsvc.c +++ b/dlls/schedsvc/atsvc.c @@ -623,6 +623,47 @@ void add_job(const WCHAR *name) LeaveCriticalSection(&at_job_list_section); }
+static inline BOOL is_file(const WIN32_FIND_DATAW *data) +{ + return !(data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); +} + +void load_at_tasks(void) +{ + static const WCHAR tasksW[] = { '\','T','a','s','k','s','\',0 }; + static const WCHAR allW[] = { '*',0 }; + WCHAR windir[MAX_PATH], path[MAX_PATH]; + WIN32_FIND_DATAW data; + HANDLE handle; + + GetWindowsDirectoryW(windir, MAX_PATH); + lstrcpyW(path, windir); + lstrcatW(path, tasksW); + lstrcatW(path, allW); + + handle = FindFirstFileW(path, &data); + if (handle == INVALID_HANDLE_VALUE) return; + + do + { + if (is_file(&data)) + { + lstrcpyW(path, windir); + lstrcatW(path, tasksW); + + if (lstrlenW(path) + lstrlenW(data.cFileName) < MAX_PATH) + { + lstrcatW(path, data.cFileName); + add_job(path); + } + else + FIXME("too long file name %s\n", debugstr_w(data.cFileName)); + } + } while (FindNextFileW(handle, &data)); + + FindClose(handle); +} + static BOOL write_signature(HANDLE hfile) { struct diff --git a/dlls/schedsvc/schedsvc_private.h b/dlls/schedsvc/schedsvc_private.h index d601030e78..10892d55ca 100644 --- a/dlls/schedsvc/schedsvc_private.h +++ b/dlls/schedsvc/schedsvc_private.h @@ -30,6 +30,7 @@ void add_process_to_queue(HANDLE hproc) DECLSPEC_HIDDEN; void update_process_status(DWORD pid) DECLSPEC_HIDDEN; BOOL get_next_runtime(LARGE_INTEGER *rt) DECLSPEC_HIDDEN; void check_task_time(void) DECLSPEC_HIDDEN; +void load_at_tasks(void) DECLSPEC_HIDDEN;
static inline WCHAR *heap_strdupW(const WCHAR *src) { diff --git a/dlls/schedsvc/svc_main.c b/dlls/schedsvc/svc_main.c index 0dfac818fd..2bba674b07 100644 --- a/dlls/schedsvc/svc_main.c +++ b/dlls/schedsvc/svc_main.c @@ -53,6 +53,8 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
TRACE("Starting...\n");
+ load_at_tasks(); + htimer = CreateWaitableTimerW(NULL, FALSE, NULL); if (htimer == NULL) {