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

📄 pcadll.cpp

📁 face recognition test source code
💻 CPP
字号:
#include "stdafx.h"

//#include "pcadllh.h"    
#include "str.h"    
#include <math.h>
//#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <myexcpt.h>

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

#include "afxdllx.h"    // standard MFC Extension DLL routines

static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };

extern "C" int CALLBACK LibMain(HINSTANCE hInstance, WORD, WORD, LPSTR)
	{
	// Extension DLL one-time initialization - do not allocate memory here,
	//   use the TRACE or ASSERT macros or call MessageBox
	AfxInitExtensionModule(extensionDLL, hInstance);
	return 1;   // ok
	}

// Exported DLL initialization is run in context of running application
extern "C" extern void WINAPI InitPcaDLL()
	{
	// create a new CDynLinkLibrary for this app
	new CDynLinkLibrary(extensionDLL);
	// nothing more to do
	} 
	
struct MOREINFO
	{
	time_t ttime;
	};

struct MOREINFO mi[10];
int level = 0;

void GiveProcess()
	{    
	MSG msg;

	while (PeekMessage(&msg, NULL, NULL, NULL, PM_NOYIELD | PM_REMOVE) && msg.message != WM_QUIT)
		{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
		}

   if (msg.message == WM_QUIT)
		{
		return;
		}
	}


void Msg(int next_level, char *format, ...)
	{
	unsigned long mem_total;
	char msg[300], msg_more[100];
	va_list ap;
	char str[200];
	int i, h, m, s, ms;
	long ttime, ttime2;
	char msg_mem_total[10];
	
	if (next_level < 0)
		{
		level += next_level;
		
		// Get the free memory available
		mem_total = GlobalCompact(0);						//GetFreeSpace(0);
		ByteToStr(msg_mem_total, mem_total);
		
		if (level < 10)
			{        
			time(&ttime);										/*ttime = number of sec since 1/1/1970*/
			ttime -= mi[level].ttime;						/*ttime = number of sec since the message of the same level*/
			ttime2 = ttime;
			h = floor((double)ttime/3600.0);				/*number of hours*/
			ttime -= h * 3600;
			m = floor((double)ttime/60.0);				/*minuts*/
			ttime -= m * 60;
			s = ttime;											/*seconds*/
			ms = 0;
			}
		
		if (h > 0)
			sprintf(msg_more, str_MSG_MORE_H, h, m, msg_mem_total);
		else
			{
			if (m > 0)
				sprintf(msg_more, str_MSG_MORE_M, m, s, msg_mem_total);
			else
				{
				sprintf(msg_more, str_MSG_MORE_S, s, msg_mem_total);
				}
			}
		}
	
	if (strlen(format) == 0)
		return;
	
	strcpy(str, "");
	for (i = 0; i < level; i++)
		{
		strcat(str, "     ");
		}
	strcat(str, format);
	
	va_start(ap, format);
	vsprintf(msg, str, ap);
	va_end(ap);
	
	if (next_level < 0)
		strcat(msg, msg_more);
	
	strcat(msg, "\r");
	AfxGetApp()->m_pMainWnd->SendMessage(WM_PUTINFO, 0, (long)(&(msg[0])));
	//gApplication->m_pDoc->SetMsg(msg);
	
	if (next_level > 0)
		{
		time(&(mi[level].ttime));
		level += next_level;
		}
	}

void ByteToStr(char *str, long byte)
	{
	if (byte >= 1048576)
		{
		sprintf(str, "%.2f M", (float)byte/1048576.0);
		return;
		}
		
	if (byte >= 1024)
		{
		sprintf(str, "%.2f k", (float)byte/1024.0);
		return;
		}
	sprintf(str, "%ld b", byte);
	}

void Fail(int err)
	{
	CMyException *excpt = new CMyException(err);
	THROW(excpt);
	}

long lmin(long i1, long i2)
	{
	if (i1 < i2)
		return i1;
	else
		return i2; 
	}

⌨️ 快捷键说明

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