mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
Regedit: Now restores last position on startup
Still need to save position on exit svn path=/trunk/; revision=18270
This commit is contained in:
parent
3df2610b06
commit
f8b4f3f219
3 changed files with 59 additions and 8 deletions
|
@ -34,6 +34,7 @@
|
|||
#include "main.h"
|
||||
#include "hexedit.h"
|
||||
#include "security.h"
|
||||
#include "regproc.h"
|
||||
|
||||
BOOL ProcessCmdLine(LPSTR lpCmdLine);
|
||||
|
||||
|
@ -74,6 +75,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
{
|
||||
BOOL AclUiAvailable;
|
||||
HMENU hEditMenu;
|
||||
TCHAR szBuffer[256];
|
||||
LPCTSTR s;
|
||||
|
||||
WNDCLASSEX wcFrame = {
|
||||
sizeof(WNDCLASSEX),
|
||||
|
@ -158,6 +161,19 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
SetupStatusBar(hFrameWnd, FALSE);
|
||||
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
|
||||
}
|
||||
|
||||
/* Restore position */
|
||||
if (RegQueryStringValue(HKEY_CURRENT_USER,
|
||||
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit"),
|
||||
_T("LastKey"),
|
||||
szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0])) == ERROR_SUCCESS)
|
||||
{
|
||||
s = szBuffer;
|
||||
if (!_tcsncmp(s, _T("My Computer\\"), 12))
|
||||
s += 12;
|
||||
SelectNode(g_pChildWnd->hTreeWnd, s);
|
||||
}
|
||||
|
||||
ShowWindow(hFrameWnd, nCmdShow);
|
||||
UpdateWindow(hFrameWnd);
|
||||
return TRUE;
|
||||
|
|
|
@ -1659,8 +1659,42 @@ LONG RegRenameValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpDestValue, LPCTSTR lp
|
|||
RegDeleteValue(hKey, lpSrcValue);
|
||||
|
||||
done:
|
||||
if (hKey)
|
||||
RegCloseKey(hKey);
|
||||
if (hSubKey)
|
||||
RegCloseKey(hSubKey);
|
||||
return lResult;
|
||||
}
|
||||
|
||||
LONG RegQueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen)
|
||||
{
|
||||
LONG lResult;
|
||||
HKEY hSubKey = NULL;
|
||||
DWORD cbData, dwType;
|
||||
|
||||
if (lpSubKey)
|
||||
{
|
||||
lResult = RegOpenKey(hKey, lpSubKey, &hSubKey);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
goto done;
|
||||
hKey = hSubKey;
|
||||
}
|
||||
|
||||
cbData = (dwBufferLen - 1) * sizeof(*pszBuffer);
|
||||
lResult = RegQueryValueEx(hKey, lpValueName, NULL, &dwType, (LPBYTE) pszBuffer, &cbData);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
goto done;
|
||||
if (dwType != REG_SZ)
|
||||
{
|
||||
lResult = -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
pszBuffer[cbData / sizeof(*pszBuffer)] = '\0';
|
||||
|
||||
done:
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
pszBuffer[0] = '\0';
|
||||
if (hSubKey)
|
||||
RegCloseKey(hSubKey);
|
||||
return lResult;
|
||||
}
|
||||
|
||||
|
@ -1674,22 +1708,22 @@ BOOL RegKeyGetName(LPTSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCTSTR lp
|
|||
|
||||
if (hRootKey == HKEY_CLASSES_ROOT)
|
||||
pszRootKey = TEXT("HKEY_CLASSES_ROOT");
|
||||
else if (hRootKey == HKEY_CURRENT_USER)
|
||||
else if (hRootKey == HKEY_CURRENT_USER)
|
||||
pszRootKey = TEXT("HKEY_CURRENT_USER");
|
||||
else if (hRootKey == HKEY_LOCAL_MACHINE)
|
||||
else if (hRootKey == HKEY_LOCAL_MACHINE)
|
||||
pszRootKey = TEXT("HKEY_LOCAL_MACHINE");
|
||||
else if (hRootKey == HKEY_USERS)
|
||||
else if (hRootKey == HKEY_USERS)
|
||||
pszRootKey = TEXT("HKEY_USERS");
|
||||
else if (hRootKey == HKEY_CURRENT_CONFIG)
|
||||
else if (hRootKey == HKEY_CURRENT_CONFIG)
|
||||
pszRootKey = TEXT("HKEY_CURRENT_CONFIG");
|
||||
else if (hRootKey == HKEY_DYN_DATA)
|
||||
else if (hRootKey == HKEY_DYN_DATA)
|
||||
pszRootKey = TEXT("HKEY_DYN_DATA");
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
if (lpSubKey[0])
|
||||
_sntprintf(pszDest, iDestLength, TEXT("%s\\%s"), pszRootKey, lpSubKey);
|
||||
else
|
||||
else
|
||||
_sntprintf(pszDest, iDestLength, TEXT("%s"), pszRootKey);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ LONG RegCopyKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR lpSrc
|
|||
LONG RegMoveKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR lpSrcSubKey);
|
||||
LONG RegRenameKey(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpNewName);
|
||||
LONG RegRenameValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpDestValue, LPCTSTR lpSrcValue);
|
||||
LONG RegQueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen);
|
||||
|
||||
/*
|
||||
* Miscellaneous
|
||||
|
|
Loading…
Reference in a new issue