- Revenera Community
- FlexNet Connect
- FlexNet Connect Forum
- Download events... C++ example?
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Printer Friendly Page
Download events... C++ example?
I was basically wondering if anyone has some C++ code that I could look at which receive the events generated by IUpdate.
Any help would be much appreciated!
#import "C:\Program Files\Common Files\InstallShield\UpdateService\Agent.exe" named_guids no_namespace raw_interfaces_only
// Sink class to receive update events
class CUpdateEventSink :
public IDispEventImpl<1, CUpdateEventSink, &DIID__IUpdateEvents, &LIBID_DWUpdateServiceLib, 1, 0>
// IUpdateEvent callback implementation
void __stdcall OnDownloadBegin();
void __stdcall OnDownloadComplete(long nResult);
void __stdcall OnProgressChanged(long nBytes, long nPercent, BSTR strTransferRate, BSTR strTimeRemaining);
void __stdcall OnUpdateBegin();
void __stdcall OnUpdateComplete(long nReturnCode);
// Event sink map
SINK_ENTRY_EX(1, DIID__IUpdateEvents, 0x1, OnDownloadBegin)
SINK_ENTRY_EX(1, DIID__IUpdateEvents, 0x2, OnProgressChanged)
SINK_ENTRY_EX(1, DIID__IUpdateEvents, 0x3, OnDownloadComplete)
SINK_ENTRY_EX(1, DIID__IUpdateEvents, 0x4, OnUpdateBegin)
SINK_ENTRY_EX(1, DIID__IUpdateEvents, 0x5, OnUpdateComplete)
// example code to receive events :
// IMPORTANT : Use MTA threading if you're using a non-
/ message pump class
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
// enum updates here
// Connect event sink
CUpdateEventSink* pSink = new CUpdateEventSink
HRESULT hr = pSink->DispEventAdvise(spUpdate)
// Receive events ...
// Release event sink
HRESULTS hr = pSink->DispEventUnadvise(spUpdate);
My question is, where DIID__IUpdateEvents, LIBID_DWUpdateServiceLib come from
where are they declared. If it has something to do with the importing of the
agent.exe then is there any other way to
declare them since im using the dispatch method to connect to agent.exe
The 3rd parameter is in reference to the dispatch ID of the event on the interface. E.g. the number 0x1 refers to the first event in the list for IUpdateEvents ( in this that's OnDownloadBegin ). The number 0x2 would refer to the 2nd method in the list, OnProgressChanged, and so-forth. The ordering of those numbers is most easily accessed by opening agent.exe using the Object Browser of Visual Studio ( or whatever tool you have's equivalent ).
More information on that ATL macro can be found here:
I've followed the example in the Reference guide for downloading and installing and the example mentioned above and I'm still not able get the events to fire. I'm using FNC 11.6 and VS2005?
Any help will be greatly appreciated!!
I don't know that there is somebody answer my answer or not. How might I characterize the third parameter in the SINK_ENTRY_EX(1, DIID__IUpdateEvents, 0x1, OnDownloadBegin) kindly in the event that somebody who might be listening notice this answer.