Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

COM programming problem


  • Please log in to reply

#1
scicatur

scicatur

    Member

  • Member
  • PipPip
  • 16 posts
I have a really painful problem...

I am doing a C++ program (compiler mingw) and I am trying to make use of Microsoft COM DLL.. Everything seems working fine until the following:
REFIID riid;
void* iLitWriter;

hr = pUnkLitWriter->QueryInterface( riid, &iLitWriter );

Now I know that riid should somewhat contain the UUID that is given in the .idl file that describes the contents of the .dll..

snippet from the .idl file:
[object, uuid(9EC81687-D4F9-4b20-969A-222BC00CE50A)]
interface ILITWriter : IUnknown
{
    //+-----------------------------------------------------------------------
    //

Now just how I should initialize the "riid" variable ??? I really tried hard to find solution by my own but came up with nothing useful.

Edited by scicatur, 14 May 2005 - 10:42 AM.

  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
ill leave this to C++ experts

but try initializing it to completely made up dif UUID

im vb guy, but im trying to help

what is this 4 if u dont mind me asking??

Stu Design

Edited by stu_design, 16 May 2005 - 11:10 AM.

  • 0

#3
scicatur

scicatur

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts
Ok I got the solution to this from another forum:

and it is this: Have to write my own litgen.h like follows:

#include <initguid.h>   // for some compilers the name of this may be different

extern "C" {
    .
    .
   DEFINE_GUID( IID_ILITWriter, 0x9EC81687,0xD4F9,0x4b20,0x96,0x9A,0x22,0x2B,0xC0,0x0C,0xE5,0x0A);
    .
    .
}

now here the DEFINE_GUID is a macro from initguid.h that binds the hex values to some structure and makes the name IID_ILITWriter meaningful. From this on the IID_ILITWriter is an initialized variable of type REFIID and can be passed to the QueryInterface method.

As you may notice the values above are taken from the .idl , just as I suspected.

stu_design:

I am writing a simple commandline application for windows that will convert OEB (Open eBook) file collections (== almost same as having an eBook in HTML format) into Microsoft Reader ebooks (.lit files). For the purpose of creating .lit files Microsoft provides 'Content SDK' which is free to download and to use for non-commercial purposes. The key component in 'Content SDK' is the litgen.dll this is COM DLL but not every COM feature is implemented. Usage guide and sample code comes with 'Content SDK'. BUT the sample code for using litgen.dll is written for Visual C++. Now the Visual C++ is expensive and in my opinion "obfuscating" environment. I much more prefer e.g. mingw compiler which is totally free of charge gcc variant (GNU license), really lean and small, capable of creating all types of windows applications and libraries. And for mingw there is this really good free IDE: Dev-C++ by BloodshedSoftware (under GNU license also).

Visual C++ is obfuscating because there is no attempt whatsoever to keep things simple. Microsoft just loads macros on top of macros in attempt to make all things running "behind the curtains". This was my experience when I used Visual C++ in my previous office.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP