Accessing this Component from C/C++

Jan 26, 2010 at 8:35 PM

I am having trouble with how to use this component in a C/C++ environment.  Do you have any examples of how to prototype the various methods?

Is LoadLibrary("PrinterQueueWatch.dll") with GetProcAddress the way to do it?

Also what should my prototypes look like in C for the XJobEvent callbacks?

Jan 27, 2010 at 6:40 AM

I'm afraid it is (most likely*) not possible to use this component from a non-managed (i.e. non .NET) C++ program.

I think your best bet is to use the underlying API calls more directly.  However there is a Windows SDK (or maybe DDK) example that uses FindFirstPrnterChangeNotification in C... see for details.

Jan 27, 2010 at 1:40 PM

Thank you very much for the prompt response.  It is appreciated. 

I would like to clarify one thing you wrote.  When you say non-managed (non .NET) C++ program - does this mean the limitation is on the component side or on the VC++ Tool side?

I use Visual C++ v6.0 for an IE ActiveX control addin project.  It is a legacy product that must support Windows 98 up through Windows 7.  In several cases I was able to use what I believe are C# .Net components or DLL's where necessary to support various features.  Two examples:

1)  To support Protected Mode in IE for Vista, I had to Load "ieframe.dll" on XP\Vista machines to use the desired API's.

2)  To support the latest MS Word automation (to seamlessly print documents from Word),  I used  "#import  MSWORD.OLB" - this is the library provided with Office 2003.  After the import, I was able to use the Word automation directly as the import made the Word namespace available,

I believe these are making use of mscoree.dll, although I could certainly be mistaken.  So just to be sure, is there really no way to use this component in a C/C++ environment?  If not, then why do the method prototypes for the various classes also give a C++ version.  E.g.  Below is the prototype of the "JobAdded" eventhandler, and the "PrintJob" and "MonitorJobAddedEvent" properties.

public: __event EventHandler* JobAdded;
public: __property PrintJob get_PrintJob();
public: __property  bool  get_MonitorJobAddedEvent();
public: __property void set_MonitorJobAddedEvent( bool);
If it is possible, I just need to know how to get access to these properties and methods in my C/C++ sources.  Seems like Loadlibary is one possiblity, 
but I have no idea how to make the calls to set up the Event Handlers in C/C++ so that they are called from the component. Any help that you can provide, 
or even if you could point me to someone that might have done it would be appreciated. 
Jan 28, 2010 at 6:55 AM


There are basically two types of C++ - Managed C++ (also known as Visual C++ .NET) and the previous version Native C++

This component is written in .NET so it requires the .NET framework in order to work.  If you write a Managed C++ application then this application will use the .NET framework so the component can be dropped in to the application and will work.

If you are writing a native C++ application then it is possible to interact with a .NET dll using COM ( see ) but it is a significant additional overhead and I would recommend not doing this but rather writing your own native DLL (or finding one) that uses the FindFirstPrinterChangeNotification and related API calls.