diff --git a/rosapps/regedit/about.c b/rosapps/regedit/about.c index f7b75b8ed1a..6b981867b6b 100644 --- a/rosapps/regedit/about.c +++ b/rosapps/regedit/about.c @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/rosapps/regedit/childwnd.c b/rosapps/regedit/childwnd.c index fc8918fbfc0..32f08d1c670 100644 --- a/rosapps/regedit/childwnd.c +++ b/rosapps/regedit/childwnd.c @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/rosapps/regedit/childwnd.h b/rosapps/regedit/childwnd.h index 1dd38a20765..eb91603397f 100644 --- a/rosapps/regedit/childwnd.h +++ b/rosapps/regedit/childwnd.h @@ -27,10 +27,6 @@ extern "C" { #endif -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM); diff --git a/rosapps/regedit/debug.c b/rosapps/regedit/debug.c index 2ca8eeed226..f449900c2df 100644 --- a/rosapps/regedit/debug.c +++ b/rosapps/regedit/debug.c @@ -27,8 +27,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/rosapps/regedit/framewnd.c b/rosapps/regedit/framewnd.c index 468aeb84ab0..30f3b662c02 100644 --- a/rosapps/regedit/framewnd.c +++ b/rosapps/regedit/framewnd.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -189,7 +188,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; case ID_HELP_ABOUT: #ifdef WINSHELLAPI - ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT)); +// ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT)); #else ShowAboutBox(hWnd); #endif diff --git a/rosapps/regedit/framewnd.h b/rosapps/regedit/framewnd.h index 969739c3cb3..988ab97640e 100644 --- a/rosapps/regedit/framewnd.h +++ b/rosapps/regedit/framewnd.h @@ -27,10 +27,6 @@ extern "C" { #endif -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM); diff --git a/rosapps/regedit/listview.c b/rosapps/regedit/listview.c index 5cebff7ed19..5d191513fbd 100644 --- a/rosapps/regedit/listview.c +++ b/rosapps/regedit/listview.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -350,10 +349,13 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath) /* get size information and resize the buffers if necessary */ errCode = RegQueryInfoKey(hNewKey, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL); + +#define BUF_HEAD_SPACE 2 // TODO: check why this is required with ROS ??? + if (errCode == ERROR_SUCCESS) { - TCHAR* ValName = malloc(++max_val_name_len * sizeof(TCHAR)); + TCHAR* ValName = malloc(++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE); DWORD dwValNameLen = max_val_name_len; - BYTE* ValBuf = malloc(++max_val_size); + BYTE* ValBuf = malloc(++max_val_size/* + BUF_HEAD_SPACE*/); DWORD dwValSize = max_val_size; DWORD dwIndex = 0L; DWORD dwValType; @@ -369,8 +371,10 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath) dwValType = 0L; ++dwIndex; } + free(ValBuf); free(ValName); + } //ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV); // SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); diff --git a/rosapps/regedit/listview.h b/rosapps/regedit/listview.h index a90aef3c173..565960c555f 100644 --- a/rosapps/regedit/listview.h +++ b/rosapps/regedit/listview.h @@ -27,10 +27,6 @@ extern "C" { #endif -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - HWND CreateListView(HWND hwndParent, int id); BOOL RefreshListView(HWND hwndTV, HKEY hKey, LPTSTR keyPath); diff --git a/rosapps/regedit/main.c b/rosapps/regedit/main.c index dd6d6b11236..7efca1dbaba 100644 --- a/rosapps/regedit/main.c +++ b/rosapps/regedit/main.c @@ -24,11 +24,10 @@ #include #include #include -#include -#include #include #include #include +#include #include "main.h" #include "framewnd.h" @@ -144,6 +143,20 @@ int APIENTRY WinMain(HINSTANCE hInstance, { MSG msg; HACCEL hAccel; +/* + int hCrt; + FILE *hf; + AllocConsole(); + hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); + hf = _fdopen(hCrt, "w"); + *stdout = *hf; + setvbuf(stdout, NULL, _IONBF, 0); + + wprintf(L"command line exit, hInstance = %d\n", hInstance); + getch(); + FreeConsole(); + return 0; + */ if (ProcessCmdLine(lpCmdLine)) { return 0; diff --git a/rosapps/regedit/main.h b/rosapps/regedit/main.h index 985df7684c3..c0ba6540593 100644 --- a/rosapps/regedit/main.h +++ b/rosapps/regedit/main.h @@ -27,9 +27,6 @@ extern "C" { #endif -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 #include "resource.h" diff --git a/rosapps/regedit/regcmds.c b/rosapps/regedit/regcmds.c index 5c00f7281a1..ea71432652a 100644 --- a/rosapps/regedit/regcmds.c +++ b/rosapps/regedit/regcmds.c @@ -24,17 +24,20 @@ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include -#include -#include -#include -#include +#ifndef WIN32_REGDBG #include -#include +#else +#ifndef __GNUC__ +#include +#endif +#define _tfopen _wfopen +#include +#endif #include - #include + #include "regproc.h" -#include "main.h" + //////////////////////////////////////////////////////////////////////////////// // Global Variables: @@ -86,12 +89,12 @@ typedef enum { void error_unknown_switch(char chu, char *s) { if (isalpha(chu)) { - printf("%s: Undefined switch /%c!\n", getAppName(), chu); + printf("Undefined switch /%c!\n", chu); } else { - printf("%s: Alphabetic character is expected after '%c' " - "in switch specification\n", getAppName(), *(s - 1)); + printf("Alphabetic character is expected after '%c' " + "in switch specification\n", *(s - 1)); } - exit(1); + //exit(1); } BOOL ProcessCmdLine(LPSTR lpCmdLine) @@ -100,7 +103,6 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) LPSTR s = lpCmdLine; /* command line pointer */ CHAR ch = *s; /* current character */ - setAppName("regedit"); while (ch && ((ch == '-') || (ch == '/'))) { char chu; char ch2; @@ -122,10 +124,12 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) break; case '?': printf(usage); - exit(0); + return FALSE; + //exit(0); break; default: error_unknown_switch(chu, s); + return FALSE; break; } } @@ -143,6 +147,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) break; default: error_unknown_switch(chu, s); + return FALSE; break; } } else { @@ -158,56 +163,60 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) ch = *s; } } -// if (action == ACTION_UNDEF) { -// action = ACTION_ADD; -// } + if (action == ACTION_UNDEF) { + action = ACTION_ADD; + } switch (action) { case ACTION_ADD: { - CHAR filename[MAX_PATH]; + TCHAR filename[MAX_PATH]; FILE *reg_file; - get_file_name(&s, filename); + get_file_name(&s, filename, MAX_PATH); if (!filename[0]) { - printf("%s: No file name is specified\n%s", getAppName(), usage); - exit(1); + printf("No file name is specified\n%s", usage); + return FALSE; + //exit(1); } while (filename[0]) { - reg_file = fopen(filename, "r"); + reg_file = _tfopen(filename, _T("r")); if (reg_file) { processRegLines(reg_file, doSetValue); } else { perror(""); - printf("%s: Can't open file \"%s\"\n", getAppName(), filename); - exit(1); + printf("Can't open file \"%s\"\n", filename); + return FALSE; + //exit(1); } - get_file_name(&s, filename); + get_file_name(&s, filename, MAX_PATH); } break; } case ACTION_DELETE: { - CHAR reg_key_name[KEY_MAX_LEN]; - get_file_name(&s, reg_key_name); + TCHAR reg_key_name[KEY_MAX_LEN]; + get_file_name(&s, reg_key_name, KEY_MAX_LEN); if (!reg_key_name[0]) { - printf("%s: No registry key is specified for removal\n%s", getAppName(), usage); - exit(1); + 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: { - CHAR filename[MAX_PATH]; + TCHAR filename[MAX_PATH]; filename[0] = '\0'; - get_file_name(&s, filename); + get_file_name(&s, filename, MAX_PATH); if (!filename[0]) { - printf("%s: No file name is specified\n%s", getAppName(), usage); - exit(1); + printf("No file name is specified\n%s", usage); + return FALSE; + //exit(1); } if (s[0]) { - CHAR reg_key_name[KEY_MAX_LEN]; - get_file_name(&s, reg_key_name); + 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); @@ -215,7 +224,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) break; } default: - printf("%s: Unhandled action!\n", getAppName()); + printf("Unhandled action!\n"); return FALSE; } return TRUE; diff --git a/rosapps/regedit/treeview.c b/rosapps/regedit/treeview.c index b151df31b54..208b6b16e4a 100644 --- a/rosapps/regedit/treeview.c +++ b/rosapps/regedit/treeview.c @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/rosapps/regedit/treeview.h b/rosapps/regedit/treeview.h index 18b5756088c..9f971e04dcd 100644 --- a/rosapps/regedit/treeview.h +++ b/rosapps/regedit/treeview.h @@ -27,10 +27,6 @@ extern "C" { #endif -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id); BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);