📄 resorgmoduleslistctrl.cpp
字号:
/************************************************************************
*
* Resource ID Organiser Core Library
*
* (c) Copyright 2000-2003 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
* All rights reserved.
*
************************************************************************
*
* Filename : ResOrgModulesListCtrl.cpp
*
* Description : CResOrgModulesListCtrl - List control class to display
* loaded modules for the About Box
*
* Compiler : Microsoft Visual C++ 6.0, Service Pack 3 or later
* Microsoft Visual C++ .NET 2002
*
* Target
* Environment : Windows 98/NT/2000/XP
*
* NOTE:
*
* This software is provided "as is" free for personal use. All
* title and copyrights in and to the software, including but not
* limited to any images, text, etc. incorporated into it, are
* owned by Anna-Jayne Metcalfe, except where acknowledged otherwise.
*
* Your may freely to use this code in your own products, PROVIDED
* this notice is not removed or modified.
*
*
* Visit http://www.annasplace.me.uk/resorg for latest updates
*
************************************************************************
*
* MODIFICATION HISTORY:
*
* This is a controlled document. See project configuration
* control tool for latest version and full version history.
*
* $Archive: /Projects/AddIns/ResOrg/ResOrgCore/ResOrgModulesListCtrl.cpp $
* $Revision: 9 $
* $Date: 15/04/03 20:37 $
* $Author: Anna $
*
* $History: ResOrgModulesListCtrl.cpp $
*
* ***************** Version 9 *****************
* User: Anna Date: 15/04/03 Time: 20:37
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Removed unnecessary file guards (#pragma once works well enough)
* 2. Updated file banners
*
* ***************** Version 8 *****************
* User: Anna Date: 25/11/02 Time: 15:13
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed website address in banner
*
* ***************** Version 7 *****************
* User: Anna Date: 22/10/02 Time: 13:24
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed name/mail address (at last!)
*
* ***************** Version 6 *****************
* User: Andy Date: 12/06/02 Time: 22:49
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Moved the class from the NGLibrary module (it's too specific to be
* there)
*
* $Nokeywords: $
*
************************************************************************/
#include "StdAfx.h"
#include "ResOrgCore_Priv.h"
#include "ResOrgModulesListCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CResOrgModulesListCtrl
enum
{
MODULE_COLUMN = 0,
TIMESTAMP_COLUMN,
SIZE_COLUMN,
VERSION_COLUMN,
DESC_COLUMN,
VENDOR_COLUMN,
END_COLUMN,
};
static LPCTSTR szColumn[] =
{
_T("Module"),
_T("Timestamp"),
_T("Size"),
_T("Version"),
_T("Description"),
_T("Vendor")
};
static DATA_TYPE eColumnType[] =
{
DT_STRING, // Module
DT_DATETIME, // Timestamp
DT_DEC, // Size
DT_STRING, // Version
DT_STRING, // Description
DT_STRING // Vendor
};
CResOrgModulesListCtrl::CResOrgModulesListCtrl(void)
{
m_pState = NULL;
}
CResOrgModulesListCtrl::~CResOrgModulesListCtrl(void)
{
}
BEGIN_MESSAGE_MAP(CResOrgModulesListCtrl, CResOrgModulesListCtrl_BASE)
//{{AFX_MSG_MAP(CResOrgModulesListCtrl)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResOrgModulesListCtrl virtual overrides
void CResOrgModulesListCtrl::PreSubclassWindow(void)
{
// TODO: Add your specialized code here and/or call the base class
CResOrgModulesListCtrl_BASE::PreSubclassWindow();
Initialise();
}
/******************************************************************************
* Sort the contents of the control by the specified column
*
******************************************************************************/
bool CResOrgModulesListCtrl::SortList(int nColumn, bool bAscending)
{
CResOrgModulesListCtrl_BASE::SortList(nColumn, bAscending);
if (nColumn >= 0)
{
CResOrgModulesListCtrl_BASE::SortList(nColumn, bAscending);
CCJSortClass sorter(this, nColumn);
sorter.Sort(bAscending, eColumnType[nColumn]);
return true;
}
return false;
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgModulesListCtrl operations
bool CResOrgModulesListCtrl::Initialise(AFX_MODULE_STATE* pState)
{
m_pState = pState;
return true;
}
void CResOrgModulesListCtrl::Refresh(void)
{
DeleteAllItems();
CModuleInfoArray arrayModules;
GetModuleInfo(arrayModules);
for (int n = 0; n < arrayModules.GetSize(); n++)
{
CModuleInfo& info = arrayModules[n];
CNGSplitPath split(info.sModuleName);
CString sModule = split.GetFileName() + split.GetExtension();
int nItem = InsertItem(GetItemCount(), sModule);
ASSERT(nItem >= 0);
if (nItem >= 0)
{
CString sSize;
sSize.Format(_T("%d"), info.nSize);
CString sTimeStamp = info.timeModified.Format( _T("%c") );
SetItemText(nItem, TIMESTAMP_COLUMN, sTimeStamp);
SetItemText(nItem, SIZE_COLUMN, sSize);
SetItemText(nItem, VERSION_COLUMN, info.sFileVersion);
SetItemText(nItem, DESC_COLUMN, info.sFileDesc);
SetItemText(nItem, VENDOR_COLUMN, info.sVendor);
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgModulesListCtrl implementation
void CResOrgModulesListCtrl::Initialise(void)
{
SetExtendedStyle(GetExtendedStyle() | LVS_EX_FULLROWSELECT);
for (int nCol = MODULE_COLUMN; nCol < END_COLUMN; nCol++)
{
AddColumn( szColumn[nCol],
-1,
LVCFMT_LEFT);
}
Refresh();
AutoSizeColumn();
}
int CResOrgModulesListCtrl::GetModuleInfo(CModuleInfoArray& rarrayModules)
{
AFX_MODULE_STATE* pState = (NULL != m_pState) ? m_pState : AfxGetAppModuleState();
if (::AfxGetAppModuleState() == pState)
{
// If the module state we've been given is that of the application, add it
// explicitly. Otherwise don't since it will probably show up in the DLL
// chain
CModuleInfo info;
GetModuleInfo(pState->m_hCurrentInstanceHandle, info);
rarrayModules.Add(info);
}
for (CDynLinkLibrary* pDLL = pState->m_libraryList; pDLL != NULL; pDLL = pDLL->m_pNextDLL)
{
CModuleInfo info;
GetModuleInfo(pDLL->m_hModule, info);
rarrayModules.Add(info);
}
return rarrayModules.GetSize();
}
void CResOrgModulesListCtrl::GetModuleInfo(HMODULE hModule, CModuleInfo& rInfo) const
{
// Get module name
LPTSTR pszName = rInfo.sModuleName.GetBuffer(_MAX_PATH);
::GetModuleFileName(hModule, pszName, _MAX_PATH);
rInfo.sModuleName.ReleaseBuffer();
// Extract version rInformation from the DLL
CNGModuleVersion ver;
ver.GetFileVersionInfo(rInfo.sModuleName);
rInfo.sFileDesc = ver.GetValue( _T("FileDescription") );
rInfo.sVendor = ver.GetValue( _T("CompanyName") );
rInfo.sFileVersion = ver.GetValue( _T("FileVersion") );
rInfo.sProductVersion = ver.GetValue( _T("ProductVersion") );
TRACE1("%s:\n", rInfo.sModuleName);
TRACE1("\tFileDescription: %s\n", rInfo.sFileDesc);
TRACE1("\tFile Version: %s\n", rInfo.sFileVersion);
// Is this a debug or release DLL?
rInfo.bDebug = ( (ver.dwFileFlags & VS_FF_DEBUG) != 0);
if (rInfo.bDebug)
{
rInfo.sFileDesc += _T(" (Debug)");
}
CFileStatus status;
if (CFile::GetStatus(rInfo.sModuleName, status) )
{
rInfo.nSize = status.m_size;
rInfo.timeCreated = status.m_ctime;
rInfo.timeModified = status.m_mtime;
}
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgModulesListCtrl message handlers
int CResOrgModulesListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CResOrgModulesListCtrl_BASE::OnCreate(lpCreateStruct) == -1)
return -1;
Initialise();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -