I created a Windows service with Delphi for a client server application. To install it I use c: Test MyService.exe /install (or /uninstall) This installs the service and in Windows services it lists with 'MyService' name and empty description. How to define a different name and insert a description (to be seen when running services.msc)? Note: I need this because on the same machine i need to install more times the same service (1 per database). Currently the only workaround i foudn is to rename the service exe, but I'd prefer to find out the correct command line way to do it (since I do this from ShellExecute). Creating a Windows Service in Delphi. Service applications let you check for updates on a system or monitor system resources, without interrupting your work. While they can be difficult to create, Delphi makes it simple. What Is Windows ServicesUpdate: Somehow i'd look for something like (this is just for explanation reasons of course! - InstallService.exe is a name i just invented): InstallService.exe c: Test MyService.exe /install /name='MyService1' /description='This is my service for database 1' but also a more compact version would be fine like: c: Test MyService.exe /install /name='MyService1' /description='This is my service for database 1'. Windows already ships with the utility that you need, namely sc create. >sc create /? DESCRIPTION: Creates a service entry in the registry and Service Database. USAGE: sc create [service name] [binPath= ]. OPTIONS: NOTE: The option name includes the equal sign. A space is required between the equal sign and the value. Type= (default = own) start= (default = demand) error= (default = normal) binPath= group= tag= depend= obj= (default = LocalSystem) DisplayName= password= This will create the service and allow you to specify the name and display name. To modify the description you need sc description: >sc description /? DESCRIPTION: Sets the description string for a service. USAGE: sc description [service name] [description] The other obvious option is to build command line parsing into your service. That's trivially easy to do. Simply assign handlers for the service's BeforeInstall and/or AfterInstall events and process the switches there. Hi, I have a Delphi windows service which uses ADOConnection to connect to SQL Server 2005 database. Some times the database need to be restarted, in this case we have to restart our service. Now we need to avoid restarting the service, instead handle this through code. The service code should reestablish connection with the database itself. Dave and busters card balance. Dave & Buster's Power Card® make having fun quick and easy! No more cash or coins. Check Power Card® or Power Tap® Balance. Enter your Power Card. Dave & Buster's - FAQs - Here are answers to commonly asked questions. To check the balance of a Power Card® without a 4 digit PIN number you must go. Sign into your Dave & Buster's Rewards Account to register your Power Card, check your chips and tickets balances, and edit your profile. Purchase your Dave & Buster's Gift Card today! Dave & Buster's gift cards can be used at any of our US locations and never. Check Gift Card Balance ›. Check the balance of your Dave and Busters gift card to see how much money you have left on your gift card. But we do not want to use timer or thread. Whenever a user senda a request from client side then the service should check connection with the database and then reestablish it if not connected. I tried this by doing Fired an arbitary query to database, if it fails then handle the exception by doing below: ADOConnection.Close; ADOConnection.Open; What this is doing is not serving the request that the client sent, but does it fine from the next time but only if a select is fired. Here I do not need to restart the service. Also if there is an update or insert fired from the client side, this does not work. Please let me know how can I restablish connection with database through service code and serve all kind of request insert update and delete. Also there is a problem by this solution. A new user is not able to connect to the service through the client. You have created a service and you don't want to use threads? If you have created a service, then the user request is handled inside a thread just catch the exception on the open, examine what error it is and when it is a connection error, attempt the open again here is a more or less pseudo code sample const ConnectionErrors: string = '4,9,2,6,0'; function ConnectionError(ErrorMessage: string): boolean; var OraError, Temp: string; begin OraError:= '; Result:= False; if AnsiContainsStr(ErrorMessage, 'ORA-') then begin Temp:= Copy(ErrorMessage, Pos('ORA-', ErrorMessage) + 4, Length(ErrorMessage)); while (Temp ') and (Temp[1] in ['0'.' 9']) do begin OraError:= OraError + Temp[1]; Delete(Temp, 1, 1); end; if (OraError ') and (Pos(OraError, ConnectionErrors) > 0) then Result:= True; end; end; procedure ServiceThread.RunQuery; var IsConnectionError: Boolean; begin IsConnectionError:= False; repeat try AdoConnection.Open except on E: Exception do begin // Examine exception message here // Depends on your database // Example oracle connection errors: // ConnectionErrors: string = '4,9,2,6,0'; if ConnectionError(E.Message) then IsConnectionError:= True; end; end; until not IsConnectionError; end; Select all.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |