I'm fairly new to COM programming and I have a DLL that compiles, but wont register when I attempt to run it. I followed this tutorial here http://msdn.microsoft.com/en-US/library/2wad1c0e(v=vs.80) and modified it to produce the code bellow. I'm not quite sure what I did wrong here.
#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()
{
}
};
This was a simple case of my RC file not having the
1 TYPELIB "SMTPSink.tlb"
line. Don't know why it wasn't there in the first place.
User contributions licensed under CC BY-SA 3.0