Need help on Windows service API

Discussion in 'Software' started by pasopati, Feb 27, 2007.

  1. pasopati

    pasopati Private E-2

    I am trying to run my application as windows service.

    I don't want to use third party sorftware like "Application as service" to accomplish the task.

    So I understand that I need to implement windows service interface in my application.

    Look guys, FYI I write my program with Ada95. Using Win32 API thin binding, I tried my best to mirror windows service interface construct.

    I know it would be much easier if I use some kind of windows service framework. Like one available in VB. But unfortunately I couldn't find one that written in Ada95 :)

    So, after I configured how a windows service should work, I wrote my program.

    Then I install the executable as windows service using Service Controler (the sc command).

    But I got error 1053. it says "The service did not respond to the start or control request in a timely fashion."

    does anyone know what makes the problem?
     
  2. pasopati

    pasopati Private E-2

    It takes all day long to figure out the simplest mistake.

    I did not take enough precaution that Win32 API is written in C. While Ada95 is strongly typed, C is not.

    In C, passing an array is done by passing the array's starting address. Just like C style string

    char[] == char *;

    Now Back to my problem writing windows service program.

    there is a procedure namely StartServiceCtrlDispatcher.

    function StartServiceCtrlDispatcher (lpServiceStartTable : access SERVICE_TABLE_ENTRYA) return Win32.BOOL

    Not knowing that it expects array of SERVICE_TABLE_ENTRYA (this array must be null terminated, just like C string), I use a pointer to single SERVICE_TABLE_ENTRYA to be the actual parameter of lpServiceStartTable. Hence, I got access violation exception. Notice that syntacticaly this is allowed. Compiler will not complaint.

    Now, My windows service that I wrote with Ada95 using win32ada binding is running well. And also, it will stop gracefully upon stop request received from service controller.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds