[SHELL32]

- Implement SHCreateSessionKey
- Formatting of shlview.cpp

svn path=/trunk/; revision=54714
This commit is contained in:
Rafal Harabien 2011-12-20 19:56:46 +00:00
parent f714427f9a
commit 673f93ef3b
3 changed files with 426 additions and 396 deletions

View file

@ -135,10 +135,54 @@ EXTERN_C HRESULT WINAPI SHRegDeleteKeyW(
/*************************************************************************
* SHRegCloseKey [SHELL32.505] NT 4.0
*
*/
EXTERN_C HRESULT WINAPI SHRegCloseKey (HKEY hkey)
{
TRACE("%p\n",hkey);
return RegCloseKey( hkey );
}
/*************************************************************************
* SHCreateSessionKey [SHELL32.723]
*/
EXTERN_C HRESULT
WINAPI
SHCreateSessionKey(REGSAM samDesired, PHKEY phKey)
{
static HKEY hSessionKey = NULL;
HRESULT hr = S_OK;
if (!hSessionKey)
{
HANDLE hToken;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &hToken))
{
TOKEN_STATISTICS Stats;
DWORD ReturnLength;
if (GetTokenInformation(hToken, TokenStatistics, &Stats, sizeof(Stats), &ReturnLength))
{
WCHAR wszBuf[256];
LONG Error;
swprintf(wszBuf,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\SessionInfo\\%08x%08x",
Stats.AuthenticationId.HighPart, Stats.AuthenticationId.LowPart);
Error = RegCreateKeyExW(HKEY_LOCAL_MACHINE, wszBuf, 0, NULL, REG_OPTION_VOLATILE, samDesired, NULL, &hSessionKey, NULL);
if (Error != ERROR_SUCCESS)
hr = HRESULT_FROM_WIN32(Error);
}
else
hr = HRESULT_FROM_WIN32(GetLastError());
CloseHandle(hToken);
}
else
hr = HRESULT_FROM_WIN32(GetLastError());
}
*phKey = hSessionKey;
return hr;
}

View file

@ -214,7 +214,8 @@ public:
{
{ sizeof(WNDCLASSEX), 0, StartWindowProc,
0, 0, NULL, NULL,
LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_BACKGROUND + 1), NULL, SV_CLASS_NAME, NULL },
LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_BACKGROUND + 1), NULL, SV_CLASS_NAME, NULL
},
NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
};
return wc;
@ -1232,7 +1233,6 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
{
WORD x;
WORD y;
BOOL bDefault;
UINT uCommand;
DWORD wFlags;
HMENU hMenu;
@ -1247,9 +1247,8 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
x = LOWORD(lParam);
y = HIWORD(lParam);
bDefault = FALSE;
TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",this, x, y, bDefault);
TRACE("(%p)->(0x%08x 0x%08x) stub\n", this, x, y);
fExplore = FALSE;
hwndTree = NULL;
@ -1284,16 +1283,8 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
if (FolderSettings.fFlags & FWF_DESKTOP)
SetMenuDefaultItem(hMenu, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);
if (bDefault)
{
TRACE("-- get menu default command\n");
uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
}
else
{
TRACE("-- track popup\n");
uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD, x, y, 0, m_hWnd, NULL);
}
if (uCommand > 0)
{
@ -1303,10 +1294,8 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
{
TRACE("-- dlg: OnDefaultCommand\n");
if (OnDefaultCommand() != S_OK)
{
OpenSelectedItems();
}
}
else
{
TRACE("-- explore -- invoke command\n");
@ -2387,10 +2376,18 @@ HRESULT STDMETHODCALLTYPE CDefView::SetCurrentViewMode(UINT ViewMode)
means. */
switch (ViewMode)
{
case FVM_ICON: dwStyle = LVS_ICON; break;
case FVM_DETAILS: dwStyle = LVS_REPORT; break;
case FVM_SMALLICON: dwStyle = LVS_SMALLICON; break;
case FVM_LIST: dwStyle = LVS_LIST; break;
case FVM_ICON:
dwStyle = LVS_ICON;
break;
case FVM_DETAILS:
dwStyle = LVS_REPORT;
break;
case FVM_SMALLICON:
dwStyle = LVS_SMALLICON;
break;
case FVM_LIST:
dwStyle = LVS_LIST;
break;
default:
{
FIXME("ViewMode %d not implemented\n", ViewMode);

View file

@ -210,17 +210,6 @@ SHIsTempDisplayMode(VOID)
return FALSE;
}
/*
* Unimplemented
*/
EXTERN_C LONG
WINAPI
SHCreateSessionKey(REGSAM regSam, PHKEY phKey)
{
FIXME("SHCreateSessionKey() stub\n");
return 0;
}
/*
* Unimplemented
*/