The RegisterEvent method associates a
callback function with a specific event. The event handler is an
InetEventProc function that is invoked when the event
occurs. Arguments are passed to the function to identify the client
session, the event type and the user-defined value specified when the
event handler is registered. If the event occurs because of an error
condition, the error code will be provided to the handler.
The callback function specified by the lpEventProc
parameter must be declared using the __stdcall calling convention. This ensures the
arguments passed to the event handler are pushed on to the stack in
the correct order. Failure to use the correct calling convention will
corrupt the stack and cause the application to terminate abnormally.
The dwParam parameter is commonly used to identify the
class instance which is associated with the event that has occurred.
Applications will cast the this pointer to a
DWORD_PTR value when calling this function, and then the event handler
will cast it back to a pointer to the class instance. This gives the
handler access to the class member variables and methods.