我对 COM 编程相当陌生,我有一个可以编译的 DLL,但在我尝试运行它时不会注册。我在这里遵循了本教程http://msdn.microsoft.com/en-US/library/2wad1c0e(v=vs.80 ) 并对其进行了修改以生成下面的代码。我不太确定我在这里做错了什么。
#pragma once
#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#define _ATL_ATTRIBUTES
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
[module(type=dll,
name = "SMTPSink",
version="1.0",
uuid="0933FDCB-7CA1-41C7-BBA0-D1EF8C76F7A7",
helpstring = "SMTPSink SMTPSink type library 1.0") ];
[ emitidl ];
//SMTP server interface functions.
//#import "oaidl.idl";
//#import "ocidl.idl";
#import "msado15.dll" raw_interfaces_only no_namespace
#import "cdosys.dll" raw_interfaces_only rename_namespace("TWGSMTP") raw_native_types no_implementation
#import "seo.dll" raw_interfaces_only no_namespace
#include "Config_Loader.h"
using namespace TWGSMTP;
//struct IMessage;
[
object,
uuid("6F6CC19F-FC41-4FFD-95BD-717FFE9549E5"),
dual,
helpstring("Sink Interface"),
pointer_default(unique)
]
__interface ISink : ISMTPOnArrival
{
virtual HRESULT __stdcall OnArrival (/*[in]*/ IMessage * Msg,
/*[in,out]*/ enum CdoEventStatus * EventStatus );
};
[
coclass,
threading(apartment),
vi_progid("TWG.Sink"),
progid("TWG.Sink.1"),
version(1.0),
uuid("17349758-26FD-49C0-894C-4C59D30F95CD"),
helpstring("Sink Class")
]
class ATL_NO_VTABLE Sink:
public ISink
{
public:
Sink()
{
}
HRESULT __stdcall OnArrival (struct IMessage * Msg, enum CdoEventStatus * EventStatus );
void TestMethod();
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
};