• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Using COM objects

Can I use COM objects and their methods in a sevice application written using C SDK ie not using MFC in VC++ 6.0?
0
jas123
Asked:
jas123
  • 3
1 Solution
 
nils pipenbrinckCommented:
Sure you can.

You don't need MFC do to work with COM-Objects. (I'm not sure about the service applications, but they shouldn't cause problems).

I have a small example source which creates a IDirectDraw Interface and gets the display size. It might not work with WinNT (I'n not sure about that), but it shows that com-objects work.

btw.. I wanted to give you a short example, but I was unsure which COM-Object is easy to use.. since I work with DirectX most of the time I tried it with DDRAW.

I hope that answers your question,

  Nils Pipenbrinck

---- stupid program begins here -----

#include <windows.h>
#include <ddraw.h>
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  IDirectDraw *dd;
  if (DirectDrawCreate(0,&dd, 0)==DD_OK)
  {
    DDSURFACEDESC ddsd;
    memset (&ddsd, 0, sizeof (ddsd));
    ddsd.dwSize = sizeof (DDSURFACEDESC);
    dd->GetDisplayMode (&ddsd);
    char temp[256];
    wsprintf (temp, "display size from ddraw = %d * %d",
    ddsd.dwWidth, ddsd.dwHeight);
    dd->Release();
    MessageBox (0, temp, "infos from a com-object", 0);
  }
  return 0;
}





0
 
jas123Author Commented:
I am using only C language ie. I do not have Winmain but the method main().


When I try to declare a pointer of a com object say IDBConnect *Connect;

while compilation it gives me an error saying that
'IDBConnect' : illegal use of this type as an expression
0
 
jas123Author Commented:
Are there any settings to be made or are the lib files or the dll to be copied anywhere?
0
 
jas123Author Commented:
I have solved the above problem.

But now when I try to call a method say Connect of the object then while compilation I get an error saying that
'Connect' : is not a member of 'IDBConnect' where I have IDBConnect *Con = 0;
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now