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

📄 randomimp.cpp

📁 一个用MFC编写的进程内组件示例程序
💻 CPP
字号:
// RandomImp.cpp : implementation file
//

#include "stdafx.h"
#include "Com.h"
#include "RandomImp.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////my code
#include "irandom.h"
#include "math.h"
//// my code end

/////////////////////////////////////////////////////////////////////////////
// CRandomImp

IMPLEMENT_DYNCREATE(CRandomImp, CCmdTarget)

////my code

// {DF7A0E86-CBA9-43b0-8E5C-F7418E46FE44}
IMPLEMENT_OLECREATE(CRandomImp, "Random.Object", 
0xdf7a0e86, 0xcba9, 0x43b0, 0x8e, 0x5c, 0xf7, 0x41, 0x8e, 0x46, 0xfe, 0x44);

// {DB4E252B-A777-47e3-BAD5-BF10B8F85052}
static const GUID IID_IRandom= 
{ 0xdb4e252b, 0xa777, 0x47e3, { 0xba, 0xd5, 0xbf, 0x10, 0xb8, 0xf8, 0x50, 0x52 } };


BEGIN_INTERFACE_MAP(CRandomImp,CCmdTarget)
   INTERFACE_PART(CRandomImp,IID_IRandom,CRandom)
END_INTERFACE_MAP()
////my code end

CRandomImp::CRandomImp()
{
	////my code
	EnableAggregation();
	AfxOleLockApp();
    ////my code end

}

CRandomImp::~CRandomImp()
{
	////my code
	AfxOleUnlockApp();
	////my code end

}


BEGIN_MESSAGE_MAP(CRandomImp, CCmdTarget)
	//{{AFX_MSG_MAP(CRandomImp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRandomImp message handlers
////my code
STDMETHODIMP_(ULONG)
CRandomImp::XCRandom::AddRef()
{
	METHOD_PROLOGUE(CRandomImp,CRandom)
    return pThis->ExternalAddRef();
}

STDMETHODIMP_(ULONG)
CRandomImp::XCRandom::Release()
{
	METHOD_PROLOGUE(CRandomImp,CRandom)
    return pThis->ExternalRelease();
}


STDMETHODIMP 
CRandomImp::XCRandom::QueryInterface(REFIID riid, void** ppv)
{
   METHOD_PROLOGUE(CRandomImp,CRandom)
   return pThis->ExternalQueryInterface(&riid, ppv);
}
STDMETHODIMP
CRandomImp::XCRandom::GetRandom(int *p)
{
	*p=rand();
	return NOERROR;
}
////my code end

⌨️ 快捷键说明

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