What to know:
(1) Use VC6 to create a "service-type" EXE file
(2) How to make COM server as a background service when OS boot-up
(3) How to debug COM server
---------------------------------------------------------
Use VC6 to create a "service-type" EXE file
(1) New ATL COM APP Wizard
(2) Choose Service-Type
(3) Wizard finished
(4) Add a new ATL Object
(5) Choose "Simple Object" to create an interface
(6) Fill in "Short Name" of the new simple object
(7) The result of New created Object (Interface)
(8)
(9) Add a new method "initialize" with UTC_time_info structure
(10) add a new method "un-initialize"
(11) The results of created new methods
(12) add UTC_time_info structure in IDL file
(13) Compile
How to make COM server as a background service when OS boot-up
(1) Open a "command console" window
(2) Go to the directory where "Test_COM_service.exe" is located
(3) enter command "Test_COM_service.exe -Service"
(4) enter "services" window
(5) check the availability of "Test_COM_service"
(6) manually activate it
(7) check the correctness of COM service startup
(8) check the COM service startup correctness in task bar
How to debug COM server
(1) de-activate COM service from "services" window
(2) Open a "command console" window
(3) Go to the directory where "Test_COM_service.exe" is located
(4) enter command "Test_COM_service.exe -regserver"
(5) Open COM service VC6 project
(6) press "F5" and add some breakpoints for debugging
!!NOTES:
(1) Debugging
according to testing, it seems that if "Test_COM_service.exe -regserver" is used
instead of "Test_COM_service.exe -Service", COM service will be closed
when COM client is Release its allocated COM server instance.
(2) COM startup and release
During COM server startup, the following steps will happen
(a) COM server will initialize itself
(b) COM server will enter CServiceModule::Run() and wait for messages in
the following while-loop
MSG msg;
while (GetMessage(&msg, 0, 0, 0))
DispatchMessage(&msg);
So any code related initialization can be placed before this while-loop.
(c) When COM server is closed automatically or manually, COM server will leave
the above while loop and leave CServiceModule::Run() subsequently.
So any code related to un-initilazation can be placed after "GetMessage" while loop.
沒有留言:
張貼留言