Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Principal > Varios
Register FAQ Members List Calendar Guía de estilo Today's Posts

Coloboración Paypal con ClubDelphi

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 19/09/2008
jocey jocey is offline
Miembro
 
Join Date: Jan 2007
Posts: 111
Poder: 20
jocey Va por buen camino
Iniciar servicio de windows

Hola familia este codigo lo copie de una pagina y cuando lo compilo me da el siguiente error:

Constant expresion violate subrange bounds.

el codigo es el sgte, y el erros es en la linea que tengo subrayada en rojo.

Código Delphi [-]
function iniciarServicio (sMachine, sService: String) : Boolean;
var
  schm,
  schs: SC_Handle;
  ss: TServiceStatus;
  psTemp: PChar;
  dwChkP: DWord;
begin
  ss.dwCurrentState := -1;
  schm := OpenSCManager(PChar(sMachine), nil, SC_MANAGER_CONNECT);
  if (schm>0) then
  begin
    schs := OpenService(schm, PChar(sService), SERVICE_START or
      SERVICE_QUERY_STATUS);
    if (schs>0) then
    begin
      psTemp := nil;
      if (StartService(schs, 0, psTemp)) then
        if (QueryServiceStatus(schs, ss)) then
          while (SERVICE_RUNNING<>ss.dwCurrentState) do
          begin
            dwChkP := ss.dwCheckPoint;
            Sleep(ss.dwWaitHint);
            if (not QueryServiceStatus(schs, ss)) then
              Break;
            if (ss.dwCheckPoint < dwChkP) then
              Break;
          end;
      CloseServiceHandle(schs);
    end;
    CloseServiceHandle(schm);
  end;
  Result := SERVICE_RUNNING=ss.dwCurrentState;
end;

cualquier ayuda sera bienvenida.
Gracias de antemano
Reply With Quote
  #2  
Old 19/09/2008
DarkMan's Avatar
DarkMan DarkMan is offline
Miembro
 
Join Date: Jul 2006
Posts: 102
Poder: 21
DarkMan Va por buen camino
Quote:
Originally Posted by jocey View Post
Código Delphi [-]
 
...
  ss.dwCurrentState := -1;
...
SS.dwCurrentState es de tipo cardinal. Según la ayuda de delphi, el tipo cardinal es:

Código Delphi [-]
 
 Type        Range              Format
 Cardinal    0..4294967295      unsigned 32-bit

Si te fijas en el rango que comprende el tipo Cardinal, el -1 no esta incluido. Lo que tu haces en esa línea es asignar -1 a una variable tipo Cardinal, lo que no está permitido.
Espero que esta respuesta te sirva.
__________________
"La recompensa de una buena acción está en haberla hecho"
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
iniciar servicio mysql, error 5 JuanHC MySQL 2 18/07/2008 08:05
Problema al iniciar servicio con windows. mcalmanovici Varios 2 27/06/2008 17:13
Iniciar e instalar servicio desde un boton! JuanErasmo API de Windows 5 25/02/2007 09:57
Iniciar un servicio marceloalegre Varios 0 16/05/2005 01:01
Iniciar servicio desde linea de comandos Sergio J. Varios 3 23/12/2004 13:48


All times are GMT +2. The time now is 01:52.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi