Skip to content

Commit

Permalink
add OS Name to Connection Details (#227)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Smith <[email protected]>
  • Loading branch information
si458 authored Jan 27, 2024
1 parent 6d64ad3 commit 998e9fb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
Binary file modified meshservice/MeshService.aps
Binary file not shown.
24 changes: 13 additions & 11 deletions meshservice/MeshService.rc
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,28 @@ BEGIN
CONTROL "",IDC_IMAGE,"Static",SS_BITMAP | SS_CENTERIMAGE | SS_REALSIZEIMAGE | WS_TABSTOP,194,8,107,96,WS_EX_TRANSPARENT
END

IDD_DETAILSDIALOG DIALOGEX 0, 0, 311, 115
IDD_DETAILSDIALOG DIALOGEX 0, 0, 311, 125
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Connection Details"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,254,94,50,14
DEFPUSHBUTTON "OK",IDOK,254,104,50,14
LTEXT "Agent Status",IDC_AGENTSTATUS_TEXT,7,7,100,8
LTEXT "Unknown",IDC_STATUSTEXT,129,7,175,8,0,WS_EX_RIGHT
LTEXT "Unknown",IDC_STATUSTEXT,94,7,210,8,0,WS_EX_RIGHT
LTEXT "Agent Version",IDC_AGENT_VERSION,7,19,100,8
LTEXT "Unknown",IDC_VERSIONTEXT,129,19,175,8,0,WS_EX_RIGHT
LTEXT "Unknown",IDC_VERSIONTEXT,94,19,210,8,0,WS_EX_RIGHT
LTEXT "Group Identifier",IDC_MESH_IDENTIFIER,7,67,100,8
LTEXT "Unknown",IDC_HASHTEXT,129,67,175,8,0,WS_EX_RIGHT
LTEXT "Unknown",IDC_HASHTEXT,94,67,210,8,0,WS_EX_RIGHT
LTEXT "Group Name",IDC_MESH_NAME,7,55,100,8
LTEXT "Unknown",IDC_POLICYTEXT,129,55,175,8,0,WS_EX_RIGHT
LTEXT "Unknown",IDC_POLICYTEXT,94,55,210,8,0,WS_EX_RIGHT
LTEXT "Server Identifier",IDC_SERVER_IDENTIFIER,7,43,100,8
LTEXT "Unknown",IDC_SERVERID,129,43,175,8,0,WS_EX_RIGHT
LTEXT "Unknown",IDC_SERVERID,94,43,210,8,0,WS_EX_RIGHT
LTEXT "Server Location",IDC_SERVER_LOCATION,7,31,100,8
LTEXT "Unknown",IDC_SERVERLOCATION,129,31,175,8,SS_NOTIFY | SS_ENDELLIPSIS,WS_EX_RIGHT
CONTROL "",IDC_AUTOPROXY_CHECK,"Button",BS_AUTOCHECKBOX | BS_BITMAP | WS_TABSTOP,7,78,10,10,WS_EX_TRANSPARENT
LTEXT "Auto Proxy",IDC_AUTOPROXY_STATIC,19,79,257,8
LTEXT "Unknown",IDC_SERVERLOCATION,94,31,210,8,SS_NOTIFY | SS_ENDELLIPSIS,WS_EX_RIGHT
CONTROL "",IDC_AUTOPROXY_CHECK,"Button",BS_AUTOCHECKBOX | BS_BITMAP | WS_TABSTOP,7,93,10,10,WS_EX_TRANSPARENT
LTEXT "Auto Proxy",IDC_AUTOPROXY_STATIC,19,94,257,8
LTEXT "OS Name",IDC_OSNAME_TEXT,7,79,100,8
LTEXT "Unknown",IDC_OSNAME,129,79,175,8,0,WS_EX_RIGHT
END


Expand All @@ -161,7 +163,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 304
TOPMARGIN, 7
BOTTOMMARGIN, 108
BOTTOMMARGIN, 119
END
END
#endif // APSTUDIO_INVOKED
Expand Down
36 changes: 36 additions & 0 deletions meshservice/ServiceMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,7 @@ INT_PTR CALLBACK DialogHandler2(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
WCHAR *meshidentitifer = NULL;
WCHAR *oktext = NULL;
WCHAR *dialogtitle = NULL;
WCHAR *osname = NULL;
meshname = Duktape_GetStringPropertyValue(g_dialogCtx, -1, "MeshName", NULL);
meshid = Duktape_GetStringPropertyValue(g_dialogCtx, -1, "MeshID", NULL);
serverid = Duktape_GetStringPropertyValue(g_dialogCtx, -1, "ServerID", NULL);
Expand Down Expand Up @@ -1584,6 +1585,41 @@ INT_PTR CALLBACK DialogHandler2(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
SetWindowTextW(GetDlgItem(hDlg, IDC_STATUSTEXT), state_notrunning);
break;
}
char osnametmp[255];
#ifdef WIN32
// This is only supported on Windows 8 and above
HMODULE wsCORE = LoadLibraryExA((LPCSTR)"Ws2_32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
GetHostNameWFunc ghnw = NULL;
if (wsCORE != NULL)
{
if ((ghnw = (GetHostNameWFunc)GetProcAddress(wsCORE, (LPCSTR)"GetHostNameW")) == NULL)
{
FreeLibrary(wsCORE);
wsCORE = NULL;
}
}
if (ghnw != NULL)
{
WCHAR whostname[MAX_PATH];
if (ghnw(whostname, MAX_PATH) == 0)
{
WideCharToMultiByte(CP_UTF8, 0, whostname, -1, osnametmp, (int)sizeof(osnametmp), NULL, NULL);
}
}
else
{
gethostname(osnametmp, (int)sizeof(osnametmp));
}
if (wsCORE != NULL)
{
FreeLibrary(wsCORE);
wsCORE = NULL;
}
#else
gethostname(osnametmp, (int)sizeof(osnametmp));
#endif
osname = Dialog_GetTranslationEx(g_dialogCtx, osnametmp);
SetWindowTextW(GetDlgItem(hDlg, IDC_OSNAME), osname);
}
}
break;
Expand Down
Binary file modified meshservice/resource.h
Binary file not shown.

0 comments on commit 998e9fb

Please sign in to comment.