taskschd: Make GetFolder check whether task folder tree exists in the registry.
This commit is contained in:
parent
e12a1bdf78
commit
630354f6df
|
@ -1,5 +1,5 @@
|
|||
MODULE = taskschd.dll
|
||||
IMPORTS = oleaut32
|
||||
IMPORTS = advapi32 oleaut32
|
||||
|
||||
C_SRCS = \
|
||||
folder.c \
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#include "objbase.h"
|
||||
#include "taskschd.h"
|
||||
#include "taskschd_private.h"
|
||||
|
@ -31,6 +32,8 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(taskschd);
|
||||
|
||||
static const char root[] = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tree";
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ITaskFolder ITaskFolder_iface;
|
||||
|
@ -116,6 +119,29 @@ static HRESULT WINAPI TaskFolder_get_Name(ITaskFolder *iface, BSTR *name)
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT reg_open_folder(const WCHAR *path, HKEY *hfolder)
|
||||
{
|
||||
HKEY hroot;
|
||||
DWORD ret;
|
||||
|
||||
ret = RegCreateKeyA(HKEY_LOCAL_MACHINE, root, &hroot);
|
||||
if (ret) return HRESULT_FROM_WIN32(ret);
|
||||
|
||||
while (*path == '\\') path++;
|
||||
ret = RegOpenKeyExW(hroot, path, 0, KEY_ALL_ACCESS, hfolder);
|
||||
if (ret == ERROR_FILE_NOT_FOUND)
|
||||
ret = ERROR_PATH_NOT_FOUND;
|
||||
|
||||
RegCloseKey(hroot);
|
||||
|
||||
return HRESULT_FROM_WIN32(ret);
|
||||
}
|
||||
|
||||
static inline void reg_close_folder(HKEY hfolder)
|
||||
{
|
||||
RegCloseKey(hfolder);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI TaskFolder_get_Path(ITaskFolder *iface, BSTR *path)
|
||||
{
|
||||
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
||||
|
@ -232,6 +258,8 @@ HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **
|
|||
TaskFolder *folder;
|
||||
WCHAR *folder_path;
|
||||
int len = 0;
|
||||
HRESULT hr;
|
||||
HKEY hfolder;
|
||||
|
||||
if (path)
|
||||
{
|
||||
|
@ -260,6 +288,15 @@ HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **
|
|||
strcatW(folder_path, path);
|
||||
}
|
||||
|
||||
hr = reg_open_folder(folder_path, &hfolder);
|
||||
if (hr)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, folder_path);
|
||||
return hr;
|
||||
}
|
||||
|
||||
reg_close_folder(hfolder);
|
||||
|
||||
folder = HeapAlloc(GetProcessHeap(), 0, sizeof(*folder));
|
||||
if (!folder)
|
||||
{
|
||||
|
|
|
@ -203,7 +203,6 @@ todo_wine
|
|||
ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), "expected ERROR_INVALID_NAME, got %#x\n", hr);
|
||||
|
||||
hr = ITaskService_GetFolder(service, Wine_Folder1_Folder2, &subfolder);
|
||||
todo_wine
|
||||
ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "expected ERROR_PATH_NOT_FOUND, got %#x\n", hr);
|
||||
|
||||
hr = ITaskFolder_CreateFolder(folder, bslash, v_null, &subfolder);
|
||||
|
|
Loading…
Reference in New Issue