?? pviewce.cpp
字號:
}
}
// not found - return an impossible index
return -1;
}
BOOL CALLBACK ProcessDialogProc
(
const HWND hDlg,
const UINT uiMessage,
const WPARAM wParam,
const LPARAM lParam
)
{
BOOL bProcessedMsg = true;
DWORD dwProcess;
switch(uiMessage)
{
case WM_INITDIALOG:
{
// Specify that the dialog box should stretch full screen
SHINITDLGINFO shidi;
ZeroMemory(&shidi, sizeof(shidi));
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
if (FALSE == IsSmartphone())
{
shidi.dwFlags = shidi.dwFlags | SHIDIF_DONEBUTTON;
}
shidi.hDlg = hDlg;
// If we could not initialize the dialog box, return an error
if (!SHInitDialog(&shidi))
{
MessageBox( hDlg, StringFromResources(IDS_SHINITDIALOG_FAILED),
StringFromResources(IDS_ERROR_TITLE), MB_OK | MB_ICONSTOP );
EndDialog(hDlg, -1);
return TRUE;
}
// set up Soft Keys menu
SHMENUBARINFO mbi;
ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hDlg;
mbi.nToolBarId = IDR_PVIEWCE_SUBMENU;
mbi.hInstRes = g_hInst;
// If we could not initialize the dialog box, return an error
if (!SHCreateMenuBar(&mbi))
{
MessageBox( hDlg, StringFromResources(IDS_SHCREATEMENUBAR_FAILED),
StringFromResources(IDS_ERROR_TITLE), MB_OK | MB_ICONSTOP );
EndDialog(hDlg, -1);
return TRUE;
}
dwProcess = GetListViewProc();
// Now set the labels - look up the proc
PROCESSENTRY32 pe32 = {0};
pe32.dwSize = sizeof(pe32);
// Walk the snapshot of processes
if (Process32First(g_hProcessSnap, &pe32))
{
TCHAR szPID[12];
TCHAR szPriority[4];
TCHAR szThreadCount[8];
TCHAR szFullPath[MAX_PATH];
do
{
// if the current iteration is the process we are looking for
if (pe32.th32ProcessID == dwProcess)
{
// process name
SetDlgItemText(hDlg, IDC_PVIEWCE_PROCESS, pe32.szExeFile);
// process ID
_sntprintf(szPID, ARRAY_LENGTH(szPID),
TEXT("0x%08X"), pe32.th32ProcessID);
SetDlgItemText(hDlg, IDC_PVIEWCE_PID, szPID);
// base priority
_sntprintf(szPriority, ARRAY_LENGTH(szPriority),
TEXT("%ld"), pe32.pcPriClassBase);
SetDlgItemText(hDlg, IDC_PVIEWCE_BASEPRI, szPriority);
// thread count
_sntprintf(szThreadCount, ARRAY_LENGTH(szThreadCount),
TEXT("%ld"), pe32.cntThreads);
SetDlgItemText(hDlg, IDC_PVIEWCE_NUMTH, szThreadCount);
// type - always 32-bit, 16-bit processes aren't available
SetDlgItemText(hDlg, IDC_PVIEWCE_TYPE, TEXT("32-Bit"));
// full path
GetModuleFileName((HMODULE)pe32.th32ProcessID,
szFullPath, MAX_PATH);
SetDlgItemText(hDlg, IDC_PVIEWCE_PPATH, szFullPath);
}
} while (Process32Next(g_hProcessSnap, &pe32));
}
else
{
// couldn't walk the list of processes
EndDialog(hDlg, -1);
return TRUE;
}
break;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDM_PVIEWCE_BACK:
EndDialog(hDlg, 0);
break;
default:
bProcessedMsg = false;
break;
}
default:
// nothing was processed
bProcessedMsg = false;
break;
}
return bProcessedMsg;
}
BOOL CALLBACK ThreadDialogProc
(
const HWND hDlg,
const UINT uiMessage,
const WPARAM wParam,
const LPARAM lParam
)
{
BOOL bProcessedMsg = true;
DWORD dwCurTID = GetListViewThread();
switch(uiMessage)
{
case WM_INITDIALOG:
{
// Specify that the dialog box should stretch full screen
SHINITDLGINFO shidi;
ZeroMemory(&shidi, sizeof(shidi));
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
if (FALSE == IsSmartphone())
{
shidi.dwFlags = shidi.dwFlags | SHIDIF_DONEBUTTON;
}
shidi.hDlg = hDlg;
// If we could not initialize the dialog box, return an error
if (!SHInitDialog(&shidi))
{
MessageBox( hDlg, StringFromResources(IDS_SHINITDIALOG_FAILED),
StringFromResources(IDS_ERROR_TITLE), MB_OK | MB_ICONSTOP );
EndDialog(hDlg, -1);
return TRUE;
}
// set up Soft Keys menu
SHMENUBARINFO mbi;
ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hDlg;
mbi.nToolBarId = IDR_PVIEWCE_SUBMENU;
mbi.hInstRes = g_hInst;
// If we could not initialize the dialog box, return an error
if (!SHCreateMenuBar(&mbi))
{
MessageBox( hDlg, StringFromResources(IDS_SHCREATEMENUBAR_FAILED),
StringFromResources(IDS_ERROR_TITLE), MB_OK | MB_ICONSTOP );
EndDialog(hDlg, -1);
return TRUE;
}
// Now set the labels - look up the thread
THREADENTRY32 te32 = {0};
te32.dwSize = sizeof(THREADENTRY32);
// Walk the snapshot of threads
if (Thread32First(g_hProcessSnap, &te32))
{
TCHAR szTID[12];
TCHAR szOPID[12];
TCHAR szPriority[12];
do
{
// if the current iteration is the process we are looking for
if (te32.th32ThreadID == dwCurTID)
{
// thread ID
_sntprintf(szTID, ARRAY_LENGTH(szTID),
TEXT("0x%08X"), te32.th32ThreadID);
SetDlgItemText(hDlg, IDC_PVIEWCE_TID, szTID);
// owning PID
_sntprintf(szOPID, ARRAY_LENGTH(szOPID),
TEXT("0x%08X"), te32.th32OwnerProcessID);
SetDlgItemText(hDlg, IDC_PVIEWCE_OPID, szOPID);
// thread priority
_sntprintf(szPriority, ARRAY_LENGTH(szPriority),
TEXT("%ld"), te32.tpBasePri);
SetDlgItemText(hDlg, IDC_PVIEWCE_THRPRI, szPriority);
}
} while (Thread32Next(g_hProcessSnap, &te32));
}
else
{
// couldn't walk the list of threads
EndDialog(hDlg, -1);
return TRUE;
}
break;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDM_PVIEWCE_BACK:
EndDialog(hDlg, 0);
break;
default:
bProcessedMsg = false;
break;
}
default:
// nothing was processed
bProcessedMsg = false;
break;
}
return bProcessedMsg;
}
BOOL CALLBACK ModuleDialogProc
(
const HWND hDlg,
const UINT uiMessage,
const WPARAM wParam,
const LPARAM lParam
)
{
BOOL bProcessedMsg = true;
int iSnapIndex = PID2ArrayID(GetListViewProc());
DWORD dwCurMID = GetListViewModule();
// sanity check
if (iSnapIndex < 0)
{
EndDialog(hDlg, -1);
}
switch(uiMessage)
{
case WM_INITDIALOG:
{
// Specify that the dialog box should stretch full screen
SHINITDLGINFO shidi;
ZeroMemory(&shidi, sizeof(shidi));
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
if (FALSE == IsSmartphone())
{
shidi.dwFlags = shidi.dwFlags | SHIDIF_DONEBUTTON;
}
shidi.hDlg = hDlg;
// If we could not initialize the dialog box, return an error
if (!SHInitDialog(&shidi))
{
MessageBox( hDlg, StringFromResources(IDS_SHINITDIALOG_FAILED),
StringFromResources(IDS_ERROR_TITLE), MB_OK | MB_ICONSTOP );
EndDialog(hDlg, -1);
return TRUE;
}
// set up Soft Keys menu
SHMENUBARINFO mbi;
ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hDlg;
mbi.nToolBarId = IDR_PVIEWCE_SUBMENU;
mbi.hInstRes = g_hInst;
// If we could not initialize the dialog box, return an error
if (!SHCreateMenuBar(&mbi))
{
MessageBox( hDlg, StringFromResources(IDS_SHCREATEMENUBAR_FAILED),
StringFromResources(IDS_ERROR_TITLE), MB_OK | MB_ICONSTOP );
EndDialog(hDlg, -1);
return TRUE;
}
// we need to figure out which snapshot to use
MODULEENTRY32 me32 = {0};
me32.dwSize = sizeof(MODULEENTRY32);
// Walk the appropriate snapshot of modules
if (Module32First(g_pmsModuleSnap[iSnapIndex].hSnapShot, &me32))
{
TCHAR szHModule[12];
TCHAR szGUsage[12];
TCHAR szLUsage[12];
TCHAR szBaseAddr[12];
TCHAR szBaseSize[12];
TCHAR szFullPath[MAX_PATH];
do
{
// if the current iteration is the process we are looking for
if (me32.th32ModuleID == dwCurMID)
{
// Module Name
SetDlgItemText(hDlg, IDC_PVIEWCE_MODULE, me32.szModule);
// HModule
_sntprintf(szHModule, ARRAY_LENGTH(szHModule),
TEXT("0x%08X"), me32.hModule);
SetDlgItemText(hDlg, IDC_PVIEWCE_HMOD, szHModule);
// Global Usage
_sntprintf(szGUsage, ARRAY_LENGTH(szGUsage),
TEXT("%ld"), me32.GlblcntUsage);
SetDlgItemText(hDlg, IDC_PVIEWCE_GUSAGE, szGUsage);
// Local Usage
_sntprintf(szLUsage, ARRAY_LENGTH(szLUsage),
TEXT("%ld"), me32.ProccntUsage);
SetDlgItemText(hDlg, IDC_PVIEWCE_LUSAGE, szLUsage);
// Base Address
_sntprintf(szBaseAddr, ARRAY_LENGTH(szBaseAddr),
TEXT("0x%08X"), me32.modBaseAddr);
SetDlgItemText(hDlg, IDC_PVIEWCE_BASEADDR, szBaseAddr);
// Base Size
_sntprintf(szBaseSize, ARRAY_LENGTH(szBaseSize),
TEXT("%ld"), me32.modBaseSize);
SetDlgItemText(hDlg, IDC_PVIEWCE_BASESIZE, szBaseSize);
// Full Path
GetModuleFileName(me32.hModule, szFullPath, MAX_PATH);
SetDlgItemText(hDlg, IDC_PVIEWCE_MPATH, szFullPath);
}
} while (Module32Next(g_pmsModuleSnap[iSnapIndex].hSnapShot, &me32));
}
else
{
// couldn't walk the list of modules
EndDialog(hDlg, -1);
return TRUE;
}
break;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDM_PVIEWCE_BACK:
EndDialog(hDlg, 0);
break;
default:
bProcessedMsg = false;
break;
}
default:
// nothing was processed
bProcessedMsg = false;
break;
}
return bProcessedMsg;
}
/* EOF */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -