📄 visadm.cxx
字号:
WIN32_FIND_DATA wfd;
WCHAR *p = szBuffer + wcslen (szBuffer);
wcscpy (p, L"\\*.*");
++p;
HANDLE hSearch = FindFirstFile (szBuffer, &wfd);
if (hSearch != INVALID_HANDLE_VALUE)
{
do
{
if ((wcslen (wfd.cFileName) < _MAX_PATH - 2) && (wcscmp (wfd.cFileName, L".") != 0) &&
(wcscmp (wfd.cFileName, L"..") != 0))
{
if (wcslen (wfd.cFileName) + (pStream - szStream) + WRAPPER_SZ < MSMQ_STREAM_LEN)
{
wsprintf (pStream, L" %s" EOL, wfd.cFileName);
pStream += wcslen (pStream);
}
}
} while (FindNextFile (hSearch, &wfd));
FindClose (hSearch);
}
}
else
{
wsprintf (pStream, L"Base Dir does not exist." EOL, szBuffer);
pStream += wcslen (pStream);
}
}
}
else
{
wcscpy (pStream, EOL L"MSMQ NOT configured." EOL);
pStream += wcslen (pStream);
}
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\netreg", 0, KEY_READ, &hk) == ERROR_SUCCESS)
{
wcscpy (pStream, EOL L"NETREG configured." EOL);
pStream += wcslen (pStream);
DWORD dwType;
DWORD dw;
DWORD cb = sizeof(dw);
if ((RegQueryValueEx (hk, L"Cycle", NULL, &dwType, (LPBYTE)&dw, &cb) == ERROR_SUCCESS) &&
(dwType == REG_DWORD) && (cb == sizeof(dw)))
{
if ((pStream - szStream) + WRAPPER_SZ < MSMQ_STREAM_LEN) {
wsprintf (pStream, L"Cycle duration: %d" EOL, dw);
pStream += wcslen (pStream);
}
}
if ((RegQueryValueEx (hk, L"EmulateNB", NULL, &dwType, (LPBYTE)&dw, &cb) == ERROR_SUCCESS) &&
(dwType == REG_DWORD) && (cb == sizeof(dw)))
{
if ((pStream - szStream) + WRAPPER_SZ < MSMQ_STREAM_LEN)
{
wsprintf (pStream, L"Emulate netBIOS: %s" EOL, dw ? L"yes" : L"no");
pStream += wcslen (pStream);
}
}
if ((RegQueryValueEx (hk, L"UseRedirector", NULL, &dwType, (LPBYTE)&dw, &cb) == ERROR_SUCCESS) &&
(dwType == REG_DWORD) && (cb == sizeof(dw)))
{
if ((pStream - szStream) + WRAPPER_SZ < MSMQ_STREAM_LEN)
{
wsprintf (pStream, L"Use Redirector's netBIOS: %s" EOL, dw ? L"yes" : L"no");
pStream += wcslen (pStream);
}
}
if ((RegQueryValueEx (hk, L"TrackNetwork", NULL, &dwType, (LPBYTE)&dw, &cb) == ERROR_SUCCESS) &&
(dwType == REG_DWORD) && (cb == sizeof(dw)))
{
if ((pStream - szStream) + WRAPPER_SZ < MSMQ_STREAM_LEN)
{
wsprintf (pStream, L"Track network: %s" EOL, dw ? L"yes" : L"no");
pStream += wcslen (pStream);
}
}
RegCloseKey (hk);
} else {
wcscpy (pStream, EOL L"NETREG NOT configured." EOL);
pStream += wcslen (pStream);
}
SendMessage (GetDlgItem (g_hWnd, IDC_RESULTS), WM_SETTEXT, 0, (LPARAM)szStream);
}
// Purpose: Determine at runtime if the app is running on a smartphone device
static BOOL IsSmartphone()
{
WCHAR wszPlatform[64];
if (TRUE == SystemParametersInfo(SPI_GETPLATFORMTYPE,
sizeof(wszPlatform)/sizeof(*wszPlatform),wszPlatform,0))
{
if (0 == _wcsicmp(L"Smartphone", wszPlatform))
{
return TRUE;
}
}
return FALSE;
}
static BOOL CALLBACK DlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL fReturn = FALSE; //Default return value;
switch (uMsg)
{
case WM_INITDIALOG:
g_hWnd = hWnd;
#if defined (UNDER_CE)
// Specify that the dialog box should stretch full screen
SHINITDLGINFO shidi;
ZeroMemory(&shidi, sizeof(shidi));
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hWnd;
// If we could not initialize the dialog box, return an error
if (false == SHInitDialog(&shidi))
{
MessageBox(hWnd, TEXT("Failed to init dialog"), TEXT("Failure"), MB_OK);
//Failed to init, so quit app
EndDialog (hWnd, FALSE);
fReturn = TRUE;
}
// set up Soft Keys menu
SHMENUBARINFO mbi;
ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hWnd;
mbi.nToolBarId = IDM_VISADM_MENU;
mbi.hInstRes = g_hInst;
if (false == SHCreateMenuBar(&mbi))
{
MessageBox(hWnd, TEXT("Failed to create menu bar"), TEXT("Failure"), MB_OK);
//Failed to init, so quit app
EndDialog (hWnd, FALSE);
fReturn = TRUE;
}
//Now find out if we are a smartphone device
if (IsSmartphone())
{
// In order to make Back work properly, it's necessary to
// override it and then call the appropriate SH API
(void)SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK,
MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
//Now turn off off the edit boxes scrolls, SPh doesn't like scrolls
DWORD dwStyles = GetWindowLong(GetDlgItem(hWnd, IDC_RESULTS), GWL_STYLE);
dwStyles = dwStyles & ~(WS_VSCROLL | WS_HSCROLL);
SetWindowLong(GetDlgItem(hWnd, IDC_RESULTS), GWL_STYLE, dwStyles);
//Now create a SPh expandable edit control
HWND hWndExpander = CreateWindow(UPDOWN_CLASS, NULL,
WS_VISIBLE | UDS_ALIGNRIGHT | UDS_EXPANDABLE | UDS_NOSCROLL, 0, 0, 0, 0,
hWnd, (HMENU)IDC_RESULTS_EXPANDER, g_hInst, 0L);
SendMessage(hWndExpander, UDM_SETBUDDY, (WPARAM)GetDlgItem(hWnd, IDC_RESULTS), 0);
}
#else
//Create a desktop menu bar
SetMenu(hWnd, LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_VISADM_OPTIONS)));
#endif //UNDER_CE
SetFocus (GetDlgItem (hWnd, IDC_COMMAND));
return TRUE;
#if defined (UNDER_CE)
case WM_ACTIVATE:
if (WA_INACTIVE == LOWORD(wParam))
{
if ((NULL == lParam) || (g_hWnd == (HWND)lParam))
{
EndDialog(hWnd, 0);
}
}
break;
case WM_SIZE:
{
HWND hWndControl;
int iY, iX, iW, iH;
//Get the client window size
RECT rect;
GetClientRect(hWnd, &rect);
//Derive the size of the command edit control
iX = rect.left + WINDOW_BORDER;
iY = rect.bottom - rect.top - CONTROL_HEIGHT - WINDOW_BORDER;
iW = rect.right - rect.left - 2 * WINDOW_BORDER;
iH = CONTROL_HEIGHT;
hWndControl = GetDlgItem(hWnd, IDC_COMMAND);
MoveWindow(hWndControl, iX, iY, iW, iH, TRUE);
//Derive the size of the results edit control
iH = iY - rect.top - 2 * WINDOW_BORDER;
iY = rect.top + WINDOW_BORDER;
if (IsSmartphone())
{
//Make room for the SPh standard 10 pixel width spinner
iW -= SPINNER_WIDTH;
hWndControl = GetDlgItem(hWnd, IDC_RESULTS_EXPANDER);
MoveWindow(hWndControl, iX + iW, iY, SPINNER_WIDTH, iH, TRUE);
//Now nudge the results window width back to prevent double border
iW++;
}
//Move
hWndControl = GetDlgItem(hWnd, IDC_RESULTS);
MoveWindow(hWndControl, iX, iY, iW, iH, TRUE);
}
break;
#endif //UNDER_CE
case WM_COMMAND:
{
int wID = LOWORD(wParam);
switch (wID)
{
case IDOK:
{
WCHAR szCommand[_MAX_PATH];
SendMessage (GetDlgItem (hWnd, IDC_COMMAND), WM_GETTEXT, (WPARAM)_MAX_PATH, (LPARAM)szCommand);
RunCommand (szCommand);
return 0;
}
case IDCANCEL:
//Exit the program
EndDialog (hWnd, FALSE);
fReturn = TRUE;
break;
//Menu bar commands
case IDC_BUTTON1: // install
RunCommand (L"register install netreg");
break;
case IDC_BUTTON2: // verify
RunCommand (L"register uninstall");
break;
case IDC_BUTTON3: // register
RunCommand (L"register");
break;
case IDC_BUTTON4:
Verify ();
break;
case IDC_BUTTON5:
RunCommand (L"status");
break;
case IDC_BUTTON6:
DeliverOutput (L"\\temp\\msmq\\mqlogfile.txt");
break;
case IDC_BUTTON7:
RunCommand (L"start");
break;
case IDC_BUTTON8:
RunCommand (L"stop");
break;
}
}
break;
//WM_HOTKEY SPh specific but won't hurt a PPC app
#if defined (UNDER_CE)
case WM_HOTKEY:
if (HIWORD(lParam) == VK_TBACK)
{
SHSendBackToFocusWindow(uMsg, wParam, lParam);
}
break;
#endif //UNDER_CE
}
return fReturn;
}
#if defined (UNDER_CE)
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpszCmdLine, int nCmdShow) {
//Init the device specific controls
SHInitExtraControls();
#else
int WINAPI wWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpszCmdLine, int nCmdShow) {
#endif
g_hInst = hInst;
DialogBox (hInst, MAKEINTRESOURCE (IDD_DIALOG1), NULL, DlgProc);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -