Diodia Forum
Diodia Forum
is for all kinds of discussions of software from Diodia Software. Support
questions, feature requests and tips & tricks are
welcome.

FAQ   Search   Memberlist   Usergroups   Register

Profile   Log in to check your private
messages   Log in

Windows
Vista and IE7

Diodia
Forum Forum Index -> Diodia
ToolbarCreator

View
previous topic :: View
next topic

Author

Message

NickBasville
Site Admin

Joined: 08 Dec
2004
Posts: 127
Location: Aarhus, Denmark

Posted: Tue May
30, 2006 1:10 pm    Post
subject: Windows Vista and IE7

Hi,

In case someone
else is porting a toolbar to IE7 under Windows Vista; here's
some sample code that illustrates how to find writable
locations in the registry and in the file system when the
Internet Explorer is in protected mode:

Code:

// From KnownFolders.h (part of Vista
SDK):
#define DEFINE_KNOWN_FOLDER(name, l, w1, w2,
b1, b2, b3, b4, b5, b6, b7, b8) \
const
GUID name = { l, w1, w2, { b1, b2,  b3,
b4,  b5,  b6,  b7,  b8 } }

DEFINE_KNOWN_FOLDER(FOLDERID_InternetCache,
0x352481E8, 0x33BE, 0x4251, 0xBA, 0x85, 0x60, 0x07,
0xCA, 0xED, 0xCF, 0x9D);

typedef HRESULT
STDAPICALLTYPE IEISPROTECTEDMODEPROCESSFN (BOOL
*pbResult);
typedef HRESULT STDAPICALLTYPE
IEGETWRITEABLEHKCUFN (HKEY *phKey);
typedef HRESULT
STDAPICALLTYPE IEGETWRITEABLEFOLDERPATHFN (REFGUID
clsidFolderID, LPWSTR *lppwstrPath);

/****************************************************************************/

/*
/* DESCRIPTION : Check if the Internet
Explorer is in "protected mode".
/*
/* RETURN
VALUE: true - if it is, or unable to determine

/*
false - if it isn't
/*

/****************************************************************************/

bool IsProtectedModeProcess()
{

HINSTANCE    Instance;

IEISPROTECTEDMODEPROCESSFN
*IEIsProtectedModeProcessProc;

BOOL
IsProtecedMode = FALSE;

Instance = LoadLibrary("ieframe.dll");

if (Instance)
{

IEIsProtectedModeProcessProc =
(IEISPROTECTEDMODEPROCESSFN *) GetProcAddress(Instance,
"IEIsProtectedModeProcess");
if
(IEIsProtectedModeProcessProc)

{
HRESULT Res =
IEIsProtectedModeProcessProc(&IsProtecedMode);

if (FAILED(Res))

{

if (Res ==
0x80070005)

IsProtecedMode = TRUE; // access
denied, assume protected mode

else

IsProtecedMode =
FALSE;
}

}

FreeLibrary(Instance);
}

return IsProtecedMode ? true : false;
}

/****************************************************************************/

/*
/* DESCRIPTION : Get a writeable registry
key:
/*
/*      HKEY_CURRENT_USER

/*
- if not Windows Vista, of if IE is in unprotected
mode.
/*
/*
HKEY_CURRENT_USER/Software/Microsoft/Internet
Explorer/LowRegistry
/*
- if IE is in protected mode.

/*
/* RETURN VALUE: Registry key -
/*
use
CloseHandle() to close, if key != HKEY_CURRENT_USER

/*

/****************************************************************************/

HKEY GetWriteableHKCU()
{

HINSTANCE    Instance;

IEGETWRITEABLEHKCUFN *IEGetWriteableHKCUProc;

HKEY
Key = HKEY_CURRENT_USER;

if
(IsProtectedModeProcess())
{

Instance = LoadLibrary("ieframe.dll");

if (Instance)

{

IEGetWriteableHKCUProc = (IEGETWRITEABLEHKCUFN *)
GetProcAddress(Instance, "IEGetWriteableHKCU");

if
(IEGetWriteableHKCUProc)

{

HRESULT Res = IEGetWriteableHKCUProc(&Key);

if
(FAILED(Res))

Key = HKEY_CURRENT_USER;

}

FreeLibrary(Instance);

}
}

return
Key;
}

/****************************************************************************/

/*
/* DESCRIPTION : Get a writeable file system
location:
/*
/*      %user
profile%/AppData
/*
- if not Windows Vista, of if
IE is in unprotected mode.
/*
/*
%user profile%/../Temporary Internet Files/Low

/*
- if IE is in protected mode.
/*
/* RETURN
VALUE: Path
/*

/****************************************************************************/

std::string GetWriteableFolderPath()
{

HINSTANCE    Instance;

IEGETWRITEABLEFOLDERPATHFN
*IEGetWriteableFolderPathProc;

LPWSTR       PathToCacheLow =
NULL;
bstr_t
bPathToCacheLow;
char
PathToAppData[MAX_PATH];

std::string  Path;

if (IsProtectedModeProcess())

{
Instance =
LoadLibrary("ieframe.dll");
if
(Instance)
{

IEGetWriteableFolderPathProc =
(IEGETWRITEABLEFOLDERPATHFN *) GetProcAddress(Instance,
"IEGetWriteableFolderPath");

if (IEGetWriteableFolderPathProc)

{

HRESULT Res =
IEGetWriteableFolderPathProc(FOLDERID_InternetCache,
&PathToCacheLow);

if (SUCCEEDED(Res) &&
PathToCacheLow != NULL)

{

bPathToCacheLow = PathToCacheLow;

Path = bPathToCacheLow;

CoTaskMemFree(PathToCacheLow);

}

}

FreeLibrary(Instance);
}

}

if
(Path.empty())
{

if (SHGetSpecialFolderPath(NULL, PathToAppData,
CSIDL_APPDATA, TRUE))

Path = PathToAppData;
}

return Path;

}

-
Nick

Back
to top

Display posts from
previous: All
Posts1 Day7 Days2
Weeks1 Month3 Months6
Months1
Year Oldest FirstNewest First

Diodia
Forum Forum Index -> Diodia
ToolbarCreator

All times are
GMT - 8 Hours

Page 1 of
1

Jump to: Select a forum Diodia Software
Forums----------------Main
ChatDownload
ToolbarCooxie
ToolbarPictures
ToolbarRSS Feeds
ToolbarDiodia
ToolbarCreator

You cannot post new topics in this
forum
You cannot reply to topics in this forum
You
cannot edit your posts in this forum
You cannot
delete your posts in this forum
You cannot vote in polls
in this forum

Powered
by phpBB
© 2001, 2005 phpBB Group

Rank image|Create a new forum in our own
dedicated server