Re: COM Basics

Tech-Archive recommends: Fix windows errors by optimizing your registry




<avesty@xxxxxxxxx> wrote in message
news:1161377945.996209.12300@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I'm attempting to use the COM interface incorporated into PDFCreator
(http://www.pdfforge.org/node/407/964#comment-964). I'm an absolute
beginner when it comes to COM, so if someone could give me some
beginner tips that would be great.

So far I import the .exe with:

#import "C:\Program Files\PDFCreator\PDFCreator.exe"

In my code:
::CoInitialize(NULL);

CComPtr<__clsPDFCreator> pdfObject;

if (SUCCEEDED(pdfObject.CoCreateInstance(CLSID_clsPDFCreator)))
{
//try to do stuff with pdfObject
}

In the bit where I try to do stuff with pdfObject, none of the PDF
object methods are recognised. All give a 'is not a member of...'
error.

I don't have a header or anything, is that something I need to
generate? If so how? I have a number of examples for using COM with
pdfcreator, unfortunately none in C++ so i'm slightly lost.


The #import directive creates a *.tlh file in your Debug or Release folder.
Look there.

Add "raw_interfaces_only" as an attribute to the #import directive. This
will give you the interface names you are expecting. By default it defines
the names that are expected to be used by a smart pointer of the form
__clsPDFCreatorPtr, and pre-pends the original method names with "raw_".
This is what is confusing you. (Inspect the *.tlh file with and without the
"raw_interfaces_only" directive and you will see what I mean.)

Brian



.



Relevant Pages

  • COM Basics
    ... I'm attempting to use the COM interface incorporated into PDFCreator ... I'm an absolute ... beginner tips that would be great. ... In the bit where I try to do stuff with pdfObject, ...
    (microsoft.public.vc.atl)
  • Re: COM Basics
    ... I'm attempting to use the COM interface incorporated into PDFCreator ... I'm an absolute ... beginner tips that would be great. ... you'll endup with memory leaks and crashes. ...
    (microsoft.public.vc.atl)
  • Recommend a book for ASP.Net(Exam 70-305)
    ... I am a beginner and wish to learn ASP.NET. ... far from serving the purpose. ... Expecting a reply soon, ...
    (microsoft.public.cert.exam.mcsd)