如何来写第一个COM?就像写"HELLO WORLD"一样

来源:百度知道 编辑:UC知道 时间:2024/05/17 23:25:43
如何来写第一个COM?就像写"HELLO WORLD"一样
下面的代码可以执行吗?

COM的写法是很困难的,但是用COM却不难。
Windows游戏编程基础,这本书第5张对此略有介绍,
上面有代码抄录如下:
// DEMO5_1.CPP - A ultra minimal working COM example
// NOTE: not fully COM compliant

// INCLUDES //////////////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <malloc.h>
#include <iostream.h>
#include <objbase.h> // note: you must include this header it contains important constants
// you must use in COM programs

// GUIDS /////////////////////////////////////////////////////////////////////////////////////

// these were all generated with GUIDGEN.EXE

// {B9B8ACE1-CE14-11d0-AE58-444553540000}
const IID IID_IX =
{ 0xb9b8ace1, 0xce14, 0x11d0, { 0xae, 0x58, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };

// {B9B8ACE2-CE14-11d0-AE58-444553540000}
const IID IID_IY =
{ 0xb9b8ace2, 0xce14, 0x11d0, { 0xae, 0x58, 0x44, 0x4