/* Global variables */
HINSTANCE g_hInstance = NULL;
-TCHAR *g_szTitle; /* The title bar text */
-TCHAR *g_szWindowClass; /* Window Class Name */
+CHAR *g_szTitle; /* The title bar text */
+CHAR *g_szWindowClass; /* Window Class Name */
+CHAR *g_szComputer; /* Connected computer */
HICON g_icoStop;
HICON g_icoRun;
UINT g_bUiTaskbarCreated;
HWND g_hwndServiceDlg;
HWND g_hwndMain;
HWND g_hwndStdoutList;
+HWND g_hwndConnectDlg;
HCURSOR g_hCursorHourglass;
HCURSOR g_hCursorArrow;
LANGID g_LangID;
PROCESS_INFORMATION g_lpRedirectProc;
CRITICAL_SECTION g_stcSection;
-
+HKEY g_hKeyRemote;
/* locale language support */
static CHAR *g_lpMsg[IDS_MSG_LAST - IDS_MSG_FIRST + 1];
LPSTR GetStringRes(int id)
{
- static TCHAR buffer[MAX_PATH];
+ static CHAR buffer[MAX_PATH];
buffer[0] = 0;
LoadString(GetModuleHandle (NULL), id, buffer, MAX_PATH);
else
return FALSE;
schSCManager = OpenSCManager(
- NULL,
+ g_szComputer,
NULL,
SC_MANAGER_ALL_ACCESS
);
dwPid = 0;
schSCManager = OpenSCManager(
- NULL,
+ g_szComputer,
NULL,
SC_MANAGER_ALL_ACCESS
);
g_bRescanServices = FALSE;
- retCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ retCode = RegOpenKeyEx(g_hKeyRemote ? g_hKeyRemote : HKEY_LOCAL_MACHINE,
"System\\CurrentControlSet\\Services\\",
0, KEY_READ, &hKey);
if (retCode != ERROR_SUCCESS)
lstrcpy(szKey, "System\\CurrentControlSet\\Services\\");
lstrcat(szKey, achKey);
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0,
+ if (RegOpenKeyEx(g_hKeyRemote ? g_hKeyRemote : HKEY_LOCAL_MACHINE, szKey, 0,
KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
{
dwBufLen = MAX_PATH;
return TRUE;
}
+LRESULT CALLBACK ConnectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ CHAR szCmp[MAX_COMPUTERNAME_LENGTH+4];
+ CHAR szTmp[MAX_PATH];
+ DWORD d;
+ switch (message)
+ {
+
+ case WM_INITDIALOG:
+ ShowWindow(hDlg, SW_HIDE);
+ g_hwndConnectDlg = hDlg;
+ CenterWindow(hDlg);
+ ShowWindow(hDlg, SW_SHOW);
+ SetFocus(GetDlgItem(hDlg, IDC_COMPUTER));
+ return TRUE;
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ ZeroMemory(szCmp, MAX_COMPUTERNAME_LENGTH+4);
+ strcpy(szCmp, "\\\\");
+ SendMessage(GetDlgItem(hDlg, IDC_COMPUTER), WM_GETTEXT,
+ (WPARAM) MAX_COMPUTERNAME_LENGTH, (LPARAM) szCmp+2);
+
+ if (g_hKeyRemote)
+ RegCloseKey(g_hKeyRemote);
+ g_hKeyRemote = NULL;
+ if (RegConnectRegistry(szCmp, HKEY_LOCAL_MACHINE, &g_hKeyRemote) != ERROR_SUCCESS)
+ {
+ sprintf(szTmp, g_lpMsg[IDS_MSG_ECONNECT-IDS_MSG_FIRST], szCmp);
+ d = MAX_COMPUTERNAME_LENGTH+1;
+ GetComputerName(szCmp+2, &d);
+ ErrorMessage(szTmp, FALSE);
+ }
+ LoadString(g_hInstance, IDS_APMONITORTITLE, szTmp, MAX_LOADSTRING);
+ strcat(szTmp, "@");
+ strcat(szTmp, szCmp+2);
+ free(g_szTitle);
+ free(g_szComputer);
+ g_szTitle = strdup(szTmp);
+ g_szComputer = strdup(szCmp);
+ SetWindowText(g_hwndServiceDlg, szTmp);
+ SendMessage(g_hwndMain, WM_TIMER, WM_TIMER_RESCAN, 0);
+ case IDCANCEL:
+ EndDialog(hDlg, TRUE);
+ return TRUE;
+ }
+ break;
+ case WM_QUIT:
+ case WM_CLOSE:
+ EndDialog(hDlg, TRUE);
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ return FALSE;
+
+}
LRESULT CALLBACK ServiceDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
case WM_INITDIALOG:
ShowWindow(hDlg, SW_HIDE);
g_hwndServiceDlg = hDlg;
-
+ SetWindowText(hDlg, g_szTitle);
Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
-
+ SetWindowText(GetDlgItem(hDlg, IDC_SSTART), g_lpMsg[IDS_MSG_SSTART-IDS_MSG_FIRST]);
+ SetWindowText(GetDlgItem(hDlg, IDC_SSTOP), g_lpMsg[IDS_MSG_SSTOP-IDS_MSG_FIRST]);
+ SetWindowText(GetDlgItem(hDlg, IDC_SRESTART), g_lpMsg[IDS_MSG_SRESTART-IDS_MSG_FIRST]);
+ SetWindowText(GetDlgItem(hDlg, IDC_SMANAGER), g_lpMsg[IDS_MSG_SERVICES-IDS_MSG_FIRST]);
+ SetWindowText(GetDlgItem(hDlg, IDC_SCONNECT), g_lpMsg[IDS_MSG_CONNECT-IDS_MSG_FIRST]);
+ SetWindowText(GetDlgItem(hDlg, IDC_SEXIT), g_lpMsg[IDS_MSG_MNUEXIT-IDS_MSG_FIRST]);
if (g_dwOSVersion < OS_VERSION_WINNT)
+ {
ShowWindow(GetDlgItem(hDlg, IDC_SMANAGER), SW_HIDE);
-
+ ShowWindow(GetDlgItem(hDlg, IDC_SCONNECT), SW_HIDE);
+ }
hListBox = GetDlgItem(hDlg, IDL_SERVICES);
g_hwndStdoutList = GetDlgItem(hDlg, IDL_STDOUT);
hStatusBar = CreateStatusWindow(0x0800 /* SBT_TOOLTIPS */
EndDialog( hDlg, TRUE);
SendMessage( g_hwndMain, WM_COMMAND, (WPARAM)IDM_EXIT, 0);
return TRUE;
+ case IDC_SCONNECT:
+ DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGCONNECT),
+ hDlg, (DLGPROC)ConnectDlgProc);
+ return TRUE;
}
break;
case WM_SIZE:
ShowNotifyIcon(hWnd, NIM_ADD);
SetTimer(hWnd, WM_TIMER_REFRESH, REFRESH_TIME, NULL);
SetTimer(hWnd, WM_TIMER_RESCAN, RESCAN_TIME, NULL);
- g_hwndServiceDlg = NULL;
break;
case WM_TIMER:
switch (wParam)
g_bDlgServiceOn = FALSE;
g_hwndServiceDlg = NULL;
}
- else if (g_hwndServiceDlg)
+ else if (IsWindow(g_hwndServiceDlg))
{
/* Dirty hack to bring the window to the foreground */
SetWindowPos(g_hwndServiceDlg, HWND_TOPMOST, 0, 0, 0, 0,
g_bDlgServiceOn = FALSE;
g_hwndServiceDlg = NULL;
}
- else if (g_hwndServiceDlg)
+ else if (IsWindow(g_hwndServiceDlg))
SetFocus(g_hwndServiceDlg);
break;
case IDC_SMANAGER:
LPSTR lpCmdLine,
int nCmdShow)
{
- TCHAR szTmp[MAX_LOADSTRING];
+ CHAR szTmp[MAX_LOADSTRING];
+ CHAR szCmp[MAX_COMPUTERNAME_LENGTH+4];
MSG msg;
/* single instance mutex */
HANDLE hMutex;
int i;
+ DWORD d;
g_LangID = GetUserDefaultLangID();
if ((g_LangID & 0xFF) != LANG_ENGLISH)
g_lpMsg[i - IDS_MSG_FIRST] = strdup(szTmp);
}
LoadString(hInstance, IDS_APMONITORTITLE, szTmp, MAX_LOADSTRING);
+ strcat(szTmp, "@");
+ d = MAX_COMPUTERNAME_LENGTH+1;
+ strcpy(szCmp, "\\\\");
+ GetComputerName(szCmp+2, &d);
+ strcat(szTmp, szCmp+2);
g_szTitle = strdup(szTmp);
+ g_szComputer = strdup(szCmp);
LoadString(hInstance, IDS_APMONITORCLASS, szTmp, MAX_LOADSTRING);
g_szWindowClass = strdup(szTmp);
+ g_hKeyRemote = NULL;
g_icoStop = LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICOSTOP),
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
g_hwndMain = CreateMainWindow(hInstance);
g_bUiTaskbarCreated = RegisterWindowMessage("TaskbarCreated");
InitializeCriticalSection(&g_stcSection);
+ g_hwndServiceDlg = NULL;
if (g_hwndMain != NULL)
{
while (GetMessage(&msg, NULL, 0, 0) == TRUE)
}
am_ClearServicesSt();
}
+ if (g_hKeyRemote)
+ RegCloseKey(g_hKeyRemote);
DeleteCriticalSection(&g_stcSection);
CloseHandle(hMutex);
DestroyIcon(g_icoStop);
#include "ApacheMonitorVersion.rc"
-IDD_DLGSERVICES DIALOGEX 0, 0, 350, 174
+IDD_DLGSERVICES DIALOGEX 0, 0, 350, 188
STYLE DS_MODALFRAME | DS_SETFOREGROUND | WS_MINIMIZEBOX | WS_VISIBLE |
WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_CONTROLPARENT
LISTBOX IDL_SERVICES,2,49,285,73,LBS_OWNERDRAWFIXED |
LBS_HASSTRINGS | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT |
LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
- LISTBOX IDL_STDOUT,2,124,285,37,LBS_NOINTEGRALHEIGHT |
+ LISTBOX IDL_STDOUT,2,124,285,51,LBS_NOINTEGRALHEIGHT |
LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL
PUSHBUTTON "&Start",IDC_SSTART,298,75,50,14
PUSHBUTTON "S&top",IDC_SSTOP,298,91,50,14
PUSHBUTTON "&Restart",IDC_SRESTART,298,107,50,14
PUSHBUTTON "Ser&vices",IDC_SMANAGER,298,123,50,14
CONTROL 113,IDC_STATIC,"Static",SS_BITMAP,0,0,349,38
- PUSHBUTTON "E&xit",IDC_SEXIT,298,147,50,14
+ PUSHBUTTON "&Connect",IDC_SCONNECT,298,139,50,14
+ PUSHBUTTON "E&xit",IDC_SEXIT,298,161,50,14
+END
+
+IDD_DLGCONNECT DIALOGEX 0, 0, 186, 54
+STYLE DS_MODALFRAME | DS_SETFOREGROUND | WS_VISIBLE |
+ WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Connect Remote Computer"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "&OK",IDOK,127,31,50,14
+ LTEXT "Computer name:",IDC_LREMOTE,7,1,155,8
+ PUSHBUTTON "&Cancel",IDCANCEL,8,31,50,14
+ EDITTEXT IDC_COMPUTER,7,12,169,14,ES_AUTOHSCROLL
END
IDB_BMPSTOP BITMAP DISCARDABLE "sstop.bmp"
IDS_MSG_SSTOP "S&top"
IDS_MSG_SRESTART "&Restart"
IDS_MSG_SERVICES "Ser&vices"
+ IDS_MSG_CONNECT "&Connect"
+ IDS_MSG_ECONNECT "Unable to connect remote registry on %s"
END