⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resorgutils.cpp

📁 一个vc中管理资源文件ID的插件
💻 CPP
字号:
/************************************************************************
 *
 *                 Resource ID Organiser Utility Library
 *
 *       (c) Copyright 2000 by Andy Metcalfe (andy.metcalfe@lineone.net)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ResOrgUtils.cpp
 *
 *  Description : DLL initialization routines and global functions
 *                
 *  Compiler    : Microsoft Visual C++ 6.0, Service Pack 3 or 4
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 98/NT
 *
 *  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 Andy 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.resorg.co.uk 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/ResOrgUtils/ResOrgUtils.cpp $
 *   $Revision: 6 $
 *       $Date: 26/05/01 15:14 $
 *     $Author: Andy $
 *
 *    $History: ResOrgUtils.cpp $
 * 
 * *****************  Version 6  *****************
 * User: Andy         Date: 26/05/01   Time: 15:14
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added Mailing List prompt option
 * 
 * *****************  Version 5  *****************
 * User: Andy         Date: 5/04/01    Time: 6:10
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added support for version expiry (conditional compilation)
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 2/03/01    Time: 13:12
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added GetSymbolFileName() function [previously in CWorkspaceHelper]
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 17/02/01   Time: 7:01
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added "SymbolTypes" global helper object
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 29/11/00   Time: 18:38
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 *  Added file banners
 *
 * $Nokeywords: $
 *
 ************************************************************************/

// ResOrgUtils.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include <afxdllx.h>

#include "ResOrgUtils_Priv.h"
#include "ResOrgUtils_Res.h"

#include "ResourceSymbolTypes.h"
#include "ResOrgOptions.h"
#include "ResourceFileBuffer.h"
#include "ResOrgExpiredDlg.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


RESORGUTILS_EXT_DATA	CResOrgOptions			Options;
RESORGUTILS_EXT_DATA	CResourceSymbolTypes	SymbolTypes;


static AFX_EXTENSION_MODULE ResOrgUtilsDLL = { NULL, NULL };

extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
	// Remove this if you use lpReserved
	UNREFERENCED_PARAMETER(lpReserved);

	if (dwReason == DLL_PROCESS_ATTACH)
	{
		TRACE0("RESORGUTILS.DLL Initializing!\n");
		
		// Extension DLL one-time initialization
		if (!AfxInitExtensionModule(ResOrgUtilsDLL, hInstance))
			return 0;

		// Insert this DLL into the resource chain
		// NOTE: If this Extension DLL is being implicitly linked to by
		//  an MFC Regular DLL (such as an ActiveX Control)
		//  instead of an MFC application, then you will want to
		//  remove this line from DllMain and put it in a separate
		//  function exported from this Extension DLL.  The Regular DLL
		//  that uses this Extension DLL should then explicitly call that
		//  function to initialize this Extension DLL.  Otherwise,
		//  the CDynLinkLibrary object will not be attached to the
		//  Regular DLL's resource chain, and serious problems will
		//  result.

		new CDynLinkLibrary(ResOrgUtilsDLL);
	}
	else if (dwReason == DLL_PROCESS_DETACH)
	{
		TRACE0("RESORGUTILS.DLL Terminating!\n");
		// Terminate the library before destructors are called
		AfxTermExtensionModule(ResOrgUtilsDLL);
	}
	return 1;   // ok
}


// Exported DLL initialization is run in context of application
// or Regular DLL.
RESORGUTILS_EXT_API void WINAPI InitResOrgUtils(void)
{
   // Create a new CDynLinkLibrary for this app.
   new CDynLinkLibrary(ResOrgUtilsDLL);

   // Add other initialization here.
}


RESORGUTILS_EXT_API void DoCommonControlsVersionPrompt(const CString& sVersion)
{
	CNGMessageBox dlg;

	dlg.FormatMsgEx(MAKEINTRESOURCE(IDP_COMCTL32_VER),
					_T("RTF"),
					sVersion);

	dlg.SetRtf();
	dlg.SetStandardIcon(IDI_ERROR);
	dlg.AddButton(IDOK, TRUE, TRUE, _T("OK") );

	dlg.DoModal();
}


RESORGUTILS_EXT_API int DoMailingListQuery(void)
{
	CNGMessageBox dlg;

	dlg.SetMsgEx( MAKEINTRESOURCE(	IDP_RESORG_MAILING_LIST),
									_T("RTF") );
	dlg.SetRtf();
	dlg.SetStandardIcon(IDI_INFORMATION);
	dlg.AddButton(IDYES, TRUE, TRUE, _T("&Yes") );
	dlg.AddButton(IDNO, FALSE, FALSE, _T("&No") );

	return dlg.DoModal();
}

#ifdef _RESORG_EXPIRY_DATE

RESORGUTILS_EXT_API CTime GetVersionExpiryDate(void)
{
	return CTime(_RESORG_EXPIRY_DATE, 0, 0, 0);
}


RESORGUTILS_EXT_API BOOL IsVersionExpired(void)
{
	CTime timeNow		= CTime::GetCurrentTime();
	CTime timeExpires	= GetVersionExpiryDate();

	return (timeNow >= timeExpires);
}


RESORGUTILS_EXT_API BOOL DoVersionExpiryCheck(void)
{
	if (::IsVersionExpired() )
	{
		CResOrgExpiredDlg dlg;

		dlg.DoModal();

        return TRUE;
    }
	return FALSE;
}
#endif


RESORGUTILS_EXT_API CString GetSymbolFileName(const CString& sResourceFileName)
{
	CString sSymbolFile;

	// Read the resource file
	CStdioFile f;
	CFileException e;

	if (f.Open(	sResourceFileName,
				CFile::modeRead |
				CFile::shareDenyWrite,
				&e) )
	{
		// File opened OK
		//
		// Now create an archive, and an empty text buffer
		CArchive ar(&f, CArchive::load);
		CResourceFileBuffer buf;
		buf.Serialize(ar);

		// Close the file
		try
		{
			ar.Flush();
			ar.Close();
			f.Flush();
			f.Close();
		}
		catch (CException* e)
		{
			TCHAR szCause[255];
			e->GetErrorMessage(szCause, 255);
			CString sMsg;
			sMsg.Format( _T("The resource file could not be closed: %s\n"), szCause);

			TRACE1("%s\n", sMsg);
			AfxMessageBox(sMsg, MB_OK | MB_ICONSTOP);

			e->Delete();
		}

		CNGSplitPath splitpath(sResourceFileName);

		// Ask the buffer for the name of the symbol file
		sSymbolFile =	splitpath.GetDrive() +
						splitpath.GetDirectory() +
						buf.GetSymbolFileName();
	}
	return sSymbolFile;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -