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

📄 plugin.cpp

📁 Source code of IP Messenger for Win version 2.04
💻 CPP
字号:
static char *plugin_id = 
	"@(#)Copyright (C) H.Shirouzu 1996-2001   plugin.cpp	Ver1.47";
/* ========================================================================
	Project  Name			: IP Messenger for Win32
	Module Name				: Plug-in
	Create					: 1997-09-29(Mon)
	Update					: 2001-12-06(Thu)
	Copyright				: H.Shirouzu
	Reference				: 
	======================================================================== */

#include "tlib.h"
#include "resource.h"
#include "ipmsg.h"
#include "msgstr.h"

class Plugin {
protected:
	HINSTANCE	*plug_dll;
	int			plug_cnt;

public:
	Plugin(void);
	~Plugin();

	HINSTANCE EntryDll(char *dllName);
	BOOL ExitDll(HINSTANCE dll);
};

Plugin::Plugin(void)
{
	plug_cnt = 0;
	plug_dll = NULL;
}

Plugin::~Plugin(void)
{
	while (plug_cnt > 0)
		ExitDll(plug_dll[plug_cnt -1]);

	if (plug_dll)
		free(plug_dll);
}

HINSTANCE Plugin::EntryDll(char *dllName)
{
	HINSTANCE	dll;
	BOOL		(*pPluginInit)(void);

	if ((dll = ::LoadLibrary(dllName)) == NULL)
		return	NULL;

	if ((pPluginInit = (BOOL (*)(void))::GetProcAddress(dll, "PluginInitialize")) != NULL && pPluginInit() == TRUE)
	{
		if ((plug_dll = (HINSTANCE *)realloc(plug_dll, sizeof(HINSTANCE) * (plug_cnt + 1))) != NULL)
		{
			plug_dll[plug_cnt++] = dll;
			return	dll;
		}
	}

	::FreeLibrary(dll);
	return	NULL;
}

BOOL Plugin::ExitDll(HINSTANCE dll)
{
	BOOL	(*pPlugTerm)(void);

	for (int cnt=0; cnt < plug_cnt; cnt++)
	{
		if (plug_dll[cnt] != dll)
			continue;
		if ((pPlugTerm = (BOOL (*)(void))::GetProcAddress(plug_dll[cnt], "PluginTermiante")) != NULL)
			pPlugTerm();
		::FreeLibrary(plug_dll[cnt]);
		memmove(plug_dll + cnt, plug_dll + cnt +1, (--plug_cnt - cnt) * sizeof(HINSTANCE));
		return	TRUE;
	}
	return	FALSE;
}

⌨️ 快捷键说明

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