Commit 9413a198 authored by Carlo Bramini's avatar Carlo Bramini Committed by Alexandre Julliard

hhctrl.ocx: Expand environment vars in file name.

parent 451f9666
......@@ -97,7 +97,7 @@ static const char *command_to_string(UINT command)
#undef X
}
static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD buflen, WCHAR **index, WCHAR **window)
static BOOL resolve_filename(const WCHAR *env_filename, WCHAR *fullname, DWORD buflen, WCHAR **index, WCHAR **window)
{
const WCHAR *extra;
WCHAR chm_file[MAX_PATH];
......@@ -106,12 +106,25 @@ static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD bufle
static const WCHAR delimW[] = {':',':',0};
static const WCHAR delim2W[] = {'>',0};
filename = skip_schema(filename);
DWORD env_len;
WCHAR *filename;
env_filename = skip_schema(env_filename);
/* the format is "helpFile[::/index][>window]" */
if (index) *index = NULL;
if (window) *window = NULL;
env_len = ExpandEnvironmentStringsW(env_filename, NULL, 0);
if (!env_len)
return 0;
filename = heap_alloc(env_len * sizeof(WCHAR));
if (filename == NULL)
return 0;
ExpandEnvironmentStringsW(env_filename, filename, env_len);
extra = wcsstr(filename, delim2W);
if (extra)
{
......@@ -140,6 +153,9 @@ static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD bufle
lstrcatW(fullname, helpW);
lstrcatW(fullname, filename);
}
heap_free(filename);
return (GetFileAttributesW(fullname) != INVALID_FILE_ATTRIBUTES);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment