Added clipboard and common dialog references as well as build improvements.

svn path=/trunk/; revision=3956
This commit is contained in:
Robert Dickenson 2003-01-07 18:06:16 +00:00
parent d73cc06799
commit 299dc7ee24
11 changed files with 1002 additions and 464 deletions

View file

@ -24,23 +24,22 @@ PATH_TO_TOP = ..
TARGET = regedit TARGET = regedit
BASE_CFLAGS = -DGCC -D_WIN32_IE=0x0400 BASE_CFLAGS = -D_WIN32_IE=0x0400
RCFLAGS = -DGCC -D_WIN32_IE=0x0400 RCFLAGS = -D_WIN32_IE=0x0400
OBJS = about.o \
OBJS = framewnd.o \
childwnd.o \ childwnd.o \
listview.o \ framewnd.o \
treeview.o \
about.o \
trace.o \
hex_str.o \ hex_str.o \
listview.o \
main.o \
regcmds.o \ regcmds.o \
regproc.o \ regproc.o \
main.o treeview.o \
trace.o
LIBS = -lgdi32 -luser32 -lkernel32 -lcomctl32 LIBS = -lgdi32 -luser32 -lkernel32 -lcomctl32 -lcomdlg32
all: $(TARGET).exe all: $(TARGET).exe

View file

@ -22,12 +22,8 @@
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h> #include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <tchar.h> #include <tchar.h>
#include <process.h> #include <commctrl.h>
#include <stdio.h>
#include <assert.h> #include <assert.h>
#define ASSERT assert #define ASSERT assert

33
rosapps/regedit/dbg.h Normal file
View file

@ -0,0 +1,33 @@
#ifndef __DBG_H__
#define __DBG_H__
/*
void Assert(void* assert, const char* file, int line, void* msg);
#define ASSERT Assert(void* assert, const char* file, int line, void* msg)
#define D(_x_) \
printf("(%hS:%d)(%hS) ", __FILE__, __LINE__, __FUNCTION__); \
printf _x_;
*/
#ifdef ASSERT
#undef ASSERT
#endif
#ifdef NASSERT
#define ASSERT(x)
#else /* NASSERT */
//#define ASSERT(x) if (!(x)) { printf("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__); assert(0); }
#define ASSERT(x) if (!(x)) { printf("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__); }
#endif /* NASSERT */
#ifdef __GNUC__
#else
//#define __FUNCTION__ "unknown"
#endif /*__GNUC__*/
#endif /*__DBG_H__*/

View file

@ -20,13 +20,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h> #include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <tchar.h> #include <tchar.h>
#include <process.h> #include <commctrl.h>
#include <commdlg.h>
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "main.h" #include "main.h"
@ -36,6 +35,7 @@
#include "listview.h" #include "listview.h"
#include <shellapi.h> #include <shellapi.h>
#include "regproc.h"
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Global and Local Variables: // Global and Local Variables:
@ -150,6 +150,285 @@ static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
resize_frame_client(hWnd); resize_frame_client(hWnd);
} }
static BOOL CheckCommDlgError(HWND hWnd)
{
DWORD dwErrorCode = CommDlgExtendedError();
switch (dwErrorCode) {
case CDERR_DIALOGFAILURE:
break;
case CDERR_FINDRESFAILURE:
break;
case CDERR_NOHINSTANCE:
break;
case CDERR_INITIALIZATION:
break;
case CDERR_NOHOOK:
break;
case CDERR_LOCKRESFAILURE:
break;
case CDERR_NOTEMPLATE:
break;
case CDERR_LOADRESFAILURE:
break;
case CDERR_STRUCTSIZE:
break;
case CDERR_LOADSTRFAILURE:
break;
case FNERR_BUFFERTOOSMALL:
break;
case CDERR_MEMALLOCFAILURE:
break;
case FNERR_INVALIDFILENAME:
break;
case CDERR_MEMLOCKFAILURE:
break;
case FNERR_SUBCLASSFAILURE:
break;
default:
break;
}
return TRUE;
}
UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
OPENFILENAME* pOpenFileName;
OFNOTIFY* pOfNotify;
switch (uiMsg) {
case WM_INITDIALOG:
pOpenFileName = (OPENFILENAME*)lParam;
break;
case WM_NOTIFY:
pOfNotify = (OFNOTIFY*)lParam;
if (pOfNotify->hdr.code == CDN_INITDONE) {
}
break;
default:
break;
}
return 0L;
}
#define MAX_CUSTOM_FILTER_SIZE 50
TCHAR CustomFilterBuffer[MAX_CUSTOM_FILTER_SIZE];
TCHAR FileNameBuffer[_MAX_PATH];
TCHAR FileTitleBuffer[_MAX_PATH];
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
{
memset(pofn, 0, sizeof(OPENFILENAME));
pofn->lStructSize = sizeof(OPENFILENAME);
pofn->hwndOwner = hWnd;
pofn->hInstance = hInst;
pofn->lpstrFilter = _T("Registration Files\0*.reg\0Win9x/NT4 Registration Files (REGEDIT4)\0*.reg\0All Files (*.*)\0*.*\0\0");
pofn->lpstrCustomFilter = CustomFilterBuffer;
pofn->nMaxCustFilter = MAX_CUSTOM_FILTER_SIZE;
pofn->nFilterIndex = 0;
pofn->lpstrFile = FileNameBuffer;
pofn->nMaxFile = _MAX_PATH;
pofn->lpstrFileTitle = FileTitleBuffer;
pofn->nMaxFileTitle = _MAX_PATH;
// pofn->lpstrInitialDir = _T("");
// pofn->lpstrTitle = _T("Import Registry File");
// pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;
pofn->Flags = OFN_HIDEREADONLY;
// pofn->nFileOffset = ;
// pofn->nFileExtension = ;
// pofn->lpstrDefExt = _T("");
// pofn->lCustData = ;
// pofn->lpfnHook = ImportRegistryFile_OFNHookProc;
// pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");
// pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);
// pofn->FlagsEx = ;
return TRUE;
}
static BOOL ImportRegistryFile(HWND hWnd)
{
OPENFILENAME ofn;
InitOpenFileName(hWnd, &ofn);
ofn.lpstrTitle = _T("Import Registry File");
// ofn.lCustData = ;
if (GetOpenFileName(&ofn)) {
if (!import_registry_file(ofn.lpstrFile)) {
//printf("Can't open file \"%s\"\n", ofn.lpstrFile);
return FALSE;
}
/*
get_file_name(&s, filename, MAX_PATH);
if (!filename[0]) {
printf("No file name is specified\n%s", usage);
return FALSE;
//exit(1);
}
while (filename[0]) {
if (!import_registry_file(filename)) {
perror("");
printf("Can't open file \"%s\"\n", filename);
return FALSE;
//exit(1);
}
get_file_name(&s, filename, MAX_PATH);
}
*/
} else {
CheckCommDlgError(hWnd);
}
return TRUE;
}
static BOOL ExportRegistryFile(HWND hWnd)
{
OPENFILENAME ofn;
TCHAR ExportKeyPath[_MAX_PATH];
ExportKeyPath[0] = _T('\0');
InitOpenFileName(hWnd, &ofn);
ofn.lpstrTitle = _T("Export Registry File");
// ofn.lCustData = ;
ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER;
ofn.lpfnHook = ImportRegistryFile_OFNHookProc;
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);
if (GetSaveFileName(&ofn)) {
BOOL result;
result = export_registry_key(ofn.lpstrFile, ExportKeyPath);
//result = export_registry_key(ofn.lpstrFile, NULL);
//if (!export_registry_key(ofn.lpstrFile, NULL)) {
if (!result) {
//printf("Can't open file \"%s\"\n", ofn.lpstrFile);
return FALSE;
}
/*
TCHAR filename[MAX_PATH];
filename[0] = '\0';
get_file_name(&s, filename, MAX_PATH);
if (!filename[0]) {
printf("No file name is specified\n%s", usage);
return FALSE;
//exit(1);
}
if (s[0]) {
TCHAR reg_key_name[KEY_MAX_LEN];
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
export_registry_key(filename, reg_key_name);
} else {
export_registry_key(filename, NULL);
}
*/
} else {
CheckCommDlgError(hWnd);
}
return TRUE;
}
BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
{
#if 1
PRINTDLG pd;
ZeroMemory(&pd, sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
pd.hwndOwner = hWnd;
pd.hDevMode = NULL; // Don't forget to free or store hDevMode
pd.hDevNames = NULL; // Don't forget to free or store hDevNames
pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
pd.nCopies = 1;
pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;
if (PrintDlg(&pd) == TRUE) {
// GDI calls to render output.
DeleteDC(pd.hDC); // Delete DC when done.
}
#else
HRESULT hResult;
PRINTDLGEX pd;
hResult = PrintDlgEx(&pd);
if (hResult == S_OK) {
switch (pd.dwResultAction) {
case PD_RESULT_APPLY:
//The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked.
break;
case PD_RESULT_CANCEL:
//The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged.
break;
case PD_RESULT_PRINT:
//The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user.
break;
default:
break;
}
} else {
switch (hResult) {
case E_OUTOFMEMORY:
//Insufficient memory.
break;
case E_INVALIDARG:
// One or more arguments are invalid.
break;
case E_POINTER:
//Invalid pointer.
break;
case E_HANDLE:
//Invalid handle.
break;
case E_FAIL:
//Unspecified error.
break;
default:
break;
}
return FALSE;
}
#endif
return TRUE;
}
BOOL CopyKeyName(HWND hWnd, LPTSTR keyName)
{
BOOL result;
result = OpenClipboard(hWnd);
if (result) {
result = EmptyClipboard();
if (result) {
//HANDLE hClipData;
//hClipData = SetClipboardData(UINT uFormat, HANDLE hMem);
} else {
// error emptying clipboard
DWORD dwError = GetLastError();
}
if (!CloseClipboard()) {
// error closing clipboard
DWORD dwError = GetLastError();
}
} else {
// error opening clipboard
DWORD dwError = GetLastError();
}
return result;
}
BOOL RefreshView(HWND hWnd)
{
// TODO:
MessageBeep(-1);
MessageBeep(MB_ICONASTERISK);
MessageBeep(MB_ICONEXCLAMATION);
MessageBeep(MB_ICONHAND);
MessageBeep(MB_ICONQUESTION);
MessageBeep(MB_OK);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// //
// FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG) // FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
@ -157,11 +436,26 @@ static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
// PURPOSE: Processes WM_COMMAND messages for the main frame window. // PURPOSE: Processes WM_COMMAND messages for the main frame window.
// //
// //
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
// Parse the menu selections: // Parse the menu selections:
case ID_REGISTRY_IMPORTREGISTRYFILE:
ImportRegistryFile(hWnd);
break;
case ID_REGISTRY_EXPORTREGISTRYFILE:
ExportRegistryFile(hWnd);
break;
case ID_REGISTRY_CONNECTNETWORKREGISTRY:
break;
case ID_REGISTRY_DISCONNECTNETWORKREGISTRY:
break;
case ID_REGISTRY_PRINT:
PrintRegistryHive(hWnd, _T(""));
break;
case ID_EDIT_COPYKEYNAME:
CopyKeyName(hWnd, _T(""));
break;
case ID_REGISTRY_PRINTERSETUP: case ID_REGISTRY_PRINTERSETUP:
//PRINTDLG pd; //PRINTDLG pd;
//PrintDlg(&pd); //PrintDlg(&pd);
@ -174,7 +468,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
DestroyWindow(hWnd); DestroyWindow(hWnd);
break; break;
case ID_VIEW_REFRESH: case ID_VIEW_REFRESH:
// TODO: RefreshView(hWnd);
break; break;
// case ID_OPTIONS_TOOLBAR: // case ID_OPTIONS_TOOLBAR:
// toggle_child(hWnd, LOWORD(wParam), hToolBar); // toggle_child(hWnd, LOWORD(wParam), hToolBar);
@ -217,7 +511,7 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
switch (message) { switch (message) {
case WM_CREATE: case WM_CREATE:
{ {
pChildWnd = malloc(sizeof(ChildWnd)); pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd));
_tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH); _tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH);
hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"), hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"),
// WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER, // WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,
@ -247,7 +541,7 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
break; break;
case WM_DESTROY: case WM_DESTROY:
if (pChildWnd) { if (pChildWnd) {
free(pChildWnd); HeapFree(GetProcessHeap(), 0, pChildWnd);
pChildWnd = NULL; pChildWnd = NULL;
} }
WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0); WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);

View file

@ -24,7 +24,6 @@
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h>
#include <tchar.h> #include <tchar.h>
#include <process.h> #include <process.h>
#include <stdio.h> #include <stdio.h>
@ -93,7 +92,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
{ {
unsigned int i; unsigned int i;
LPTSTR pData = (LPTSTR)ValBuf; LPTSTR pData = (LPTSTR)ValBuf;
LPTSTR strBinary = malloc(dwCount * sizeof(TCHAR) * 3 + 1); LPTSTR strBinary = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(TCHAR) * 3 + 1);
memset(strBinary, _T(' '), dwCount * sizeof(TCHAR) * 3); memset(strBinary, _T(' '), dwCount * sizeof(TCHAR) * 3);
strBinary[dwCount * sizeof(TCHAR) * 3] = _T('\0'); strBinary[dwCount * sizeof(TCHAR) * 3] = _T('\0');
for (i = 0; i < dwCount; i++) { for (i = 0; i < dwCount; i++) {
@ -104,7 +103,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
*pShort = Byte2Hex(*(pData+i)); *pShort = Byte2Hex(*(pData+i));
} }
ListView_SetItemText(hwndLV, index, 2, strBinary); ListView_SetItemText(hwndLV, index, 2, strBinary);
free(strBinary); HeapFree(GetProcessHeap(), 0, strBinary);
} }
break; break;
default: default:
@ -353,9 +352,9 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
#define BUF_HEAD_SPACE 2 // TODO: check why this is required with ROS ??? #define BUF_HEAD_SPACE 2 // TODO: check why this is required with ROS ???
if (errCode == ERROR_SUCCESS) { if (errCode == ERROR_SUCCESS) {
TCHAR* ValName = malloc(++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE); TCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE);
DWORD dwValNameLen = max_val_name_len; DWORD dwValNameLen = max_val_name_len;
BYTE* ValBuf = malloc(++max_val_size/* + BUF_HEAD_SPACE*/); BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, ++max_val_size/* + BUF_HEAD_SPACE*/);
DWORD dwValSize = max_val_size; DWORD dwValSize = max_val_size;
DWORD dwIndex = 0L; DWORD dwIndex = 0L;
DWORD dwValType; DWORD dwValType;
@ -371,10 +370,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
dwValType = 0L; dwValType = 0L;
++dwIndex; ++dwIndex;
} }
HeapFree(GetProcessHeap(), 0, ValBuf);
free(ValBuf); HeapFree(GetProcessHeap(), 0, ValName);
free(ValName);
} }
//ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV); //ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV);
// SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); // SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV);

View file

@ -45,6 +45,9 @@ HINSTANCE hInst;
HWND hFrameWnd; HWND hFrameWnd;
HWND hStatusBar; HWND hStatusBar;
HMENU hMenuFrame; HMENU hMenuFrame;
UINT nClipboardFormat;
LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT");
TCHAR szTitle[MAX_LOADSTRING]; TCHAR szTitle[MAX_LOADSTRING];
TCHAR szFrameClass[MAX_LOADSTRING]; TCHAR szFrameClass[MAX_LOADSTRING];
@ -107,6 +110,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
// Initialize the Windows Common Controls DLL // Initialize the Windows Common Controls DLL
InitCommonControls(); InitCommonControls();
nClipboardFormat = RegisterClipboardFormat(strClipboardFormat);
if (nClipboardFormat == 0) {
DWORD dwError = GetLastError();
}
hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle, hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE, WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

View file

@ -1,4 +1,5 @@
/* /* $Id: regcmds.c,v 1.4 2003/01/07 18:06:16 robd Exp $
*
* ReactOS regedit * ReactOS regedit
* *
* regcmds.c * regcmds.c
@ -24,17 +25,13 @@
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h> #include <windows.h>
#ifndef WIN32_REGDBG
#include <tchar.h> #include <tchar.h>
#else
#ifndef __GNUC__
#include <tchar.h>
#endif
#define _tfopen _wfopen
#include <memory.h>
#endif
#include <stdio.h> #include <stdio.h>
#ifdef WIN32_REGDBG
#else
#include <ctype.h> #include <ctype.h>
#endif
#include "regproc.h" #include "regproc.h"
@ -58,6 +55,7 @@ static char *usage =
"Switches:\n" "Switches:\n"
" /E - exports contents of the specified registry key to the specified\n" " /E - exports contents of the specified registry key to the specified\n"
" file. Exports the whole registry if no key is specified.\n" " file. Exports the whole registry if no key is specified.\n"
" /P - same as /E (export) however prints output to console.\n"
" /D - deletes specified registry key\n" " /D - deletes specified registry key\n"
" /S - silent execution, can be used with any other switch.\n" " /S - silent execution, can be used with any other switch.\n"
" The only existing mode, exists for compatibility with Windows regedit.\n" " The only existing mode, exists for compatibility with Windows regedit.\n"
@ -76,7 +74,7 @@ static char *usage =
"command-line interface only.\n"; "command-line interface only.\n";
typedef enum { typedef enum {
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE, ACTION_PRINT
} REGEDIT_ACTION; } REGEDIT_ACTION;
/** /**
@ -97,6 +95,68 @@ void error_unknown_switch(char chu, char *s)
//exit(1); //exit(1);
} }
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
{
TCHAR filename[MAX_PATH];
TCHAR reg_key_name[KEY_MAX_LEN];
switch (action) {
case ACTION_ADD:
get_file_name(&s, filename, MAX_PATH);
if (!filename[0]) {
printf("No file name is specified\n%s", usage);
return FALSE;
//exit(1);
}
while (filename[0]) {
if (!import_registry_file(filename)) {
perror("");
printf("Can't open file \"%s\"\n", filename);
return FALSE;
//exit(1);
}
get_file_name(&s, filename, MAX_PATH);
}
break;
case ACTION_DELETE:
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
if (!reg_key_name[0]) {
printf("No registry key is specified for removal\n%s", usage);
return FALSE;
//exit(1);
}
delete_registry_key(reg_key_name);
break;
case ACTION_EXPORT:
filename[0] = '\0';
get_file_name(&s, filename, MAX_PATH);
if (!filename[0]) {
printf("No file name is specified\n%s", usage);
return FALSE;
//exit(1);
}
if (s[0]) {
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
export_registry_key(filename, reg_key_name);
} else {
export_registry_key(filename, NULL);
}
break;
case ACTION_PRINT:
if (s[0]) {
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
export_registry_key(NULL, reg_key_name);
} else {
export_registry_key(NULL, NULL);
}
break;
default:
printf("Unhandled action!\n");
return FALSE;
}
return TRUE;
}
BOOL ProcessCmdLine(LPSTR lpCmdLine) BOOL ProcessCmdLine(LPSTR lpCmdLine)
{ {
REGEDIT_ACTION action = ACTION_UNDEF; REGEDIT_ACTION action = ACTION_UNDEF;
@ -122,6 +182,9 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
case 'E': case 'E':
action = ACTION_EXPORT; action = ACTION_EXPORT;
break; break;
case 'P':
action = ACTION_PRINT;
break;
case '?': case '?':
printf(usage); printf(usage);
return FALSE; return FALSE;
@ -166,66 +229,5 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
if (action == ACTION_UNDEF) { if (action == ACTION_UNDEF) {
action = ACTION_ADD; action = ACTION_ADD;
} }
return PerformRegAction(action, s);
switch (action) {
case ACTION_ADD:
{
TCHAR filename[MAX_PATH];
FILE *reg_file;
get_file_name(&s, filename, MAX_PATH);
if (!filename[0]) {
printf("No file name is specified\n%s", usage);
return FALSE;
//exit(1);
}
while (filename[0]) {
reg_file = _tfopen(filename, _T("r"));
if (reg_file) {
processRegLines(reg_file, doSetValue);
} else {
perror("");
printf("Can't open file \"%s\"\n", filename);
return FALSE;
//exit(1);
}
get_file_name(&s, filename, MAX_PATH);
}
break;
}
case ACTION_DELETE:
{
TCHAR reg_key_name[KEY_MAX_LEN];
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
if (!reg_key_name[0]) {
printf("No registry key is specified for removal\n%s", usage);
return FALSE;
//exit(1);
}
delete_registry_key(reg_key_name);
break;
}
case ACTION_EXPORT:
{
TCHAR filename[MAX_PATH];
filename[0] = '\0';
get_file_name(&s, filename, MAX_PATH);
if (!filename[0]) {
printf("No file name is specified\n%s", usage);
return FALSE;
//exit(1);
}
if (s[0]) {
TCHAR reg_key_name[KEY_MAX_LEN];
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
export_registry_key(filename, reg_key_name);
} else {
export_registry_key(filename, NULL);
}
break;
}
default:
printf("Unhandled action!\n");
return FALSE;
}
return TRUE;
} }

View file

@ -1,6 +1,5 @@
#include <windows.h> //Microsoft Developer Studio generated resource script.
#include <reactos/resource.h> //
#include "resource.h" #include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
@ -66,9 +65,9 @@ BEGIN
POPUP "&Registry" POPUP "&Registry"
BEGIN BEGIN
MENUITEM "&Import Registry File...", ID_REGISTRY_IMPORTREGISTRYFILE MENUITEM "&Import Registry File...", ID_REGISTRY_IMPORTREGISTRYFILE
, GRAYED
MENUITEM "&Export Registry File...", ID_REGISTRY_EXPORTREGISTRYFILE MENUITEM "&Export Registry File...", ID_REGISTRY_EXPORTREGISTRYFILE
, GRAYED
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "&Connect Network Registry...", MENUITEM "&Connect Network Registry...",
ID_REGISTRY_CONNECTNETWORKREGISTRY ID_REGISTRY_CONNECTNETWORKREGISTRY
@ -168,14 +167,15 @@ END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
#ifndef _MAC
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Version // Version
// //
VS_VERSION_INFO VERSIONINFO (1) VERSIONINFO
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD FILEVERSION 0,0,21,3
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD PRODUCTVERSION 0,0,21,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -191,7 +191,7 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "Comments", "Absolutely no warranties whatsoever - Use at your own risk\0" VALUE "Comments", "Absolutely no warranties whatsoever - Use at your own risk\0"
VALUE "CompanyName", RES_STR_COMPANY_NAME VALUE "CompanyName", "ReactOS Development Team\0"
VALUE "FileDescription", "ReactOS Registry Editor by Robert Dickenson\0" VALUE "FileDescription", "ReactOS Registry Editor by Robert Dickenson\0"
VALUE "FileVersion", "1, 0, 0, 1\0" VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "regedit\0" VALUE "InternalName", "regedit\0"
@ -199,8 +199,8 @@ BEGIN
VALUE "LegalTrademarks", "\0" VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "regedit.exe\0" VALUE "OriginalFilename", "regedit.exe\0"
VALUE "PrivateBuild", "\0" VALUE "PrivateBuild", "\0"
VALUE "ProductName", RES_STR_PRODUCT_NAME VALUE "ProductName", "ReactOS Operating System\0"
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION VALUE "ProductVersion", "0.0.21\0"
VALUE "SpecialBuild", "Non-versioned Development Beta Release\0" VALUE "SpecialBuild", "Non-versioned Development Beta Release\0"
END END
END END
@ -210,6 +210,8 @@ BEGIN
END END
END END
#endif // !_MAC
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -255,13 +257,13 @@ BEGIN
ID_REGISTRY_DISCONNECTNETWORKREGISTRY ID_REGISTRY_DISCONNECTNETWORKREGISTRY
"Disconnects from a remote computer's registry" "Disconnects from a remote computer's registry"
ID_REGISTRY_PRINT "Prints all or part of the registry" ID_REGISTRY_PRINT "Prints all or part of the registry"
ID_HELP_HELPTOPICS "Opens registry editor help"
ID_HELP_ABOUT "Displays program information, version number and copyright" ID_HELP_ABOUT "Displays program information, version number and copyright"
END END
STRINGTABLE DISCARDABLE STRINGTABLE DISCARDABLE
BEGIN BEGIN
ID_REGISTRY_EXIT "Quits the registry editor" ID_REGISTRY_EXIT "Quits the registry editor"
ID_HELP_HELPTOPICS "Opens registry editor help"
ID_FAVOURITES_ADDTOFAVOURITES "Adds keys to the favourites list" ID_FAVOURITES_ADDTOFAVOURITES "Adds keys to the favourites list"
ID_FAVOURITES_REMOVEFAVOURITE "Removes keys from the favourites list" ID_FAVOURITES_REMOVEFAVOURITE "Removes keys from the favourites list"
ID_VIEW_STATUSBAR "Shows or hides the status bar" ID_VIEW_STATUSBAR "Shows or hides the status bar"
@ -292,13 +294,20 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
// Dialog // Dialog
// //
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 95 IDD_DIALOG1 DIALOG DISCARDABLE 50, 50, 268, 98
STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_BORDER
FONT 8, "MS Sans Serif"
BEGIN
END
IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 187, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog" CAPTION "Dialog"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14 DEFPUSHBUTTON "OK",IDOK,130,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14
END END
@ -327,7 +336,15 @@ BEGIN
IDD_DIALOG1, DIALOG IDD_DIALOG1, DIALOG
BEGIN BEGIN
LEFTMARGIN, 7 LEFTMARGIN, 7
RIGHTMARGIN, 179 RIGHTMARGIN, 261
TOPMARGIN, 7
BOTTOMMARGIN, 91
END
IDD_DIALOG2, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 180
TOPMARGIN, 7 TOPMARGIN, 7
BOTTOMMARGIN, 88 BOTTOMMARGIN, 88
END END

File diff suppressed because it is too large Load diff

View file

@ -26,48 +26,85 @@
#define SUCCESS 0 #define SUCCESS 0
#define KEY_VALUE_ALREADY_SET 2 #define KEY_VALUE_ALREADY_SET 2
typedef void (*CommandAPI)(LPSTR lpsLine); typedef void (*CommandAPI)(LPTSTR lpsLine);
void doSetValue(LPSTR lpsLine); void doSetValue(LPTSTR lpsLine);
void doDeleteValue(LPSTR lpsLine); void doDeleteValue(LPTSTR lpsLine);
void doCreateKey(LPSTR lpsLine); void doCreateKey(LPTSTR lpsLine);
void doDeleteKey(LPSTR lpsLine); void doDeleteKey(LPTSTR lpsLine);
void doQueryValue(LPSTR lpsLine); void doQueryValue(LPTSTR lpsLine);
void doRegisterDLL(LPSTR lpsLine); void doRegisterDLL(LPTSTR lpsLine);
void doUnregisterDLL(LPSTR lpsLine); void doUnregisterDLL(LPTSTR lpsLine);
void export_registry_key(CHAR* file_name, CHAR* reg_key_name); BOOL export_registry_key(TCHAR* file_name, TCHAR* reg_key_name);
void delete_registry_key(CHAR* reg_key_name); BOOL import_registry_file(LPTSTR filename);
void delete_registry_key(TCHAR* reg_key_name);
void setAppName(CHAR* name);
CHAR* getAppName(VOID);
void processRegLines(FILE* in, CommandAPI command); void processRegLines(FILE* in, CommandAPI command);
/* /*
* Generic prototypes * Generic prototypes
*/ */
#ifdef _UNICODE
#define get_file_name get_file_nameW
#else
#define get_file_name get_file_nameA
#endif
char* getToken(char** str, const char* delims); char* getToken(char** str, const char* delims);
void get_file_name(CHAR** command_line, CHAR* filename); void get_file_nameA(CHAR** command_line, CHAR* filename, int max_filename);
DWORD convertHexToDWord(char* str, BYTE* buf); void get_file_nameW(CHAR** command_line, WCHAR* filename, int max_filename);
DWORD convertHexCSVToHex(char* str, BYTE* buf, ULONG bufLen); DWORD convertHexToDWord(TCHAR* str, BYTE* buf);
LPSTR convertHexToHexCSV(BYTE* buf, ULONG len); DWORD convertHexCSVToHex(TCHAR* str, BYTE* buf, ULONG bufLen);
LPSTR convertHexToDWORDStr(BYTE* buf, ULONG len); LPTSTR convertHexToHexCSV(BYTE* buf, ULONG len);
LPSTR getRegKeyName(LPSTR lpLine); LPTSTR convertHexToDWORDStr(BYTE* buf, ULONG len);
HKEY getRegClass(LPSTR lpLine); LPTSTR getRegKeyName(LPTSTR lpLine);
DWORD getDataType(LPSTR* lpValue, DWORD* parse_type); HKEY getRegClass(LPTSTR lpLine);
LPSTR getArg(LPSTR arg); DWORD getDataType(LPTSTR* lpValue, DWORD* parse_type);
HRESULT openKey(LPSTR stdInput); LPTSTR getArg(LPTSTR arg);
HRESULT openKey(LPTSTR stdInput);
void closeKey(VOID); void closeKey(VOID);
/* /*
* api setValue prototypes * api setValue prototypes
*/ */
void processSetValue(LPSTR cmdline); void processSetValue(LPTSTR cmdline);
HRESULT setValue(LPSTR val_name, LPSTR val_data); HRESULT setValue(LPTSTR val_name, LPTSTR val_data);
/* /*
* api queryValue prototypes * api queryValue prototypes
*/ */
void processQueryValue(LPSTR cmdline); void processQueryValue(LPTSTR cmdline);
#ifdef __GNUC__
#ifdef WIN32_REGDBG
//typedef UINT_PTR SIZE_T, *PSIZE_T;
//#define _MAX_PATH 260 /* max. length of full pathname */
#endif /*WIN32_REGDBG*/
#ifdef UNICODE
#define _tfopen _wfopen
#else
#define _tfopen fopen
#endif
#endif /*__GNUC__*/
LPVOID RegHeapAlloc(
HANDLE hHeap, // handle to private heap block
DWORD dwFlags, // heap allocation control
SIZE_T dwBytes // number of bytes to allocate
);
LPVOID RegHeapReAlloc(
HANDLE hHeap, // handle to heap block
DWORD dwFlags, // heap reallocation options
LPVOID lpMem, // pointer to memory to reallocate
SIZE_T dwBytes // number of bytes to reallocate
);
BOOL RegHeapFree(
HANDLE hHeap, // handle to heap
DWORD dwFlags, // heap free options
LPVOID lpMem // pointer to memory
);

View file

@ -2,20 +2,17 @@
// Microsoft Developer Studio generated include file. // Microsoft Developer Studio generated include file.
// Used by regedit.rc // Used by regedit.rc
// //
#define ID_REGISTRY_MENU 0 #define ID_REGISTRY_MENU 0
#define ID_EDIT_MENU 1 #define ID_EDIT_MENU 1
#define ID_VIEW_MENU 2 #define ID_VIEW_MENU 2
#define ID_FAVOURITES_MENU 3 #define ID_FAVOURITES_MENU 3
#define ID_HELP_MENU 4 #define ID_HELP_MENU 4
#define ID_EDIT_NEW_MENU 5 #define ID_EDIT_NEW_MENU 5
#define IDS_LIST_COLUMN_FIRST 91 #define IDS_LIST_COLUMN_FIRST 91
#define IDS_LIST_COLUMN_NAME 91 #define IDS_LIST_COLUMN_NAME 91
#define IDS_LIST_COLUMN_TYPE 92 #define IDS_LIST_COLUMN_TYPE 92
#define IDS_LIST_COLUMN_DATA 93 #define IDS_LIST_COLUMN_DATA 93
#define IDS_LIST_COLUMN_LAST 93 #define IDS_LIST_COLUMN_LAST 93
#define IDD_ABOUTBOX 103 #define IDD_ABOUTBOX 103
#define IDS_APP_TITLE 103 #define IDS_APP_TITLE 103
#define IDI_REGEDIT 107 #define IDI_REGEDIT 107
@ -25,9 +22,10 @@
#define IDR_REGEDIT_MENU 130 #define IDR_REGEDIT_MENU 130
#define IDD_DIALOG1 131 #define IDD_DIALOG1 131
#define IDB_OPEN_FILE 132 #define IDB_OPEN_FILE 132
#define IDD_DIALOG2 132
#define IDB_CLOSED_FILE 133 #define IDB_CLOSED_FILE 133
#define IDB_ROOT 134 #define IDB_ROOT 134
#define IDC_LICENSE_EDIT 1029
#define ID_REGISTRY_EXIT 32770 #define ID_REGISTRY_EXIT 32770
#define ID_FAVOURITES_ADDTOFAVOURITES 32772 #define ID_FAVOURITES_ADDTOFAVOURITES 32772
#define ID_FAVOURITES_REMOVEFAVOURITE 32773 #define ID_FAVOURITES_REMOVEFAVOURITE 32773
@ -87,17 +85,14 @@
#define ID_REGISTRY_PRINTSUBTREE 32832 #define ID_REGISTRY_PRINTSUBTREE 32832
#define ID_REGISTRY_PRINTERSETUP 32833 #define ID_REGISTRY_PRINTERSETUP 32833
#define ID_REGISTRY_SAVESUBTREEAS 32834 #define ID_REGISTRY_SAVESUBTREEAS 32834
#define IDC_LICENSE_EDIT 1029
#define IDS_LICENSE 32835 #define IDS_LICENSE 32835
#define IDC_STATIC -1 #define IDC_STATIC -1
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 132 #define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32836 #define _APS_NEXT_COMMAND_VALUE 32836
#define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110 #define _APS_NEXT_SYMED_VALUE 110