Jump to content
Tuts 4 You

BHO project compiling errors, c++


Recommended Posts

I'm leaning BHO programming with this tutorial.

I used VC6 to compile the project, and got the error:

cannot convert from 'const struct _GUID' to 'unsigned long'

from the line:

const IID CClassFactory::SupportedIIDs[]={IID_IUnknown,IID_IClassFactory};

SupportedIIDs is an array (class member of CClassFactory) which is declared as:

private: static const IID SupportedIIDs[2];

in SDK (Guiddef.h), IID is declared as:

typedef GUID IID

typedef struct _GUID {

unsigned long Data1;

unsigned short Data2;

unsigned short Data3;

unsigned char Data4[ 8 ];


the attachment is the VC6 project.

Thank you for helping.


Edited by alaphate
Link to comment

Never looked at BHOs, or even very much COM programming, to be honest.

With that in mind, I've no idea if the mods I've made are ridiculous or just what is required to achieve a functioning program.

For the error that you mention in the following code:

const IID CClassFactory::SupportedIIDs[]={IID_IUnknown,IID_IClassFactory};

I found a solution that will compile to be:

const IID CClassFactory::SupportedIIDs[]={(unsigned long)&IID_IUnknown,(unsigned long)&IID_IClassFactory};

I then notice complaints about


which compile when turned into:


Anyhow, here's what I came up with:


Link to comment


Thank you very much for your reply.

It's more like a c++ syntax issue.

To make the question more clear, I wrote a short code below:

#include <iostream>
using namespace std;typedef struct _IID {
int a;
int b;
} IID;IID IID_HELLO = {1,2};
IID IID_WORLD = {3,4};//class with static member
class Program {
static IID arr[2]; //static member has to be initialized outside class
};//with errors blow:
IID Program::arr[] = {IID_HELLO, IID_WORLD};//if change it to:
//IID Program::arr[] = {{1,2},{3,4}}; //with no errorsint main() {
cout<<"hello world!"<<endl;
return 0;

Problem is it is not easy to find IID_IUNKOWN's instant value in the BHO prj,

so I have to keep {IID_IUnknown,IID_IClassFactory}.

the attachment is this new project.


Edited by alaphate
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...