Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Why Cant Start A service. (https://www.delphipraxis.net/48156-why-cant-start-service.html)

ZuBi 21. Jun 2005 13:27


Why Cant Start A service.
 
i wrote an service, now when trying to run him i get this:

Code:
C:\svch\dll>net start xmldrv
The Who care ha it service is starting.
The Who care ha it service could not be started.

A system error has occurred.

System error 127 has occurred.

The specified procedure could not be found.
i have regsitred service main and i dont know what couse that, did anyone mess with somthingg like this ?

Main code:

Code:
begin
installservice;
//uninstallservice;

FillChar(DispatchTable, SizeOf(DispatchTable), 0);
DispatchTable[0].lpServiceName:= PChar(S_Name);
DispatchTable[0].lpServiceProc:= @ServiceProc;
StartServiceCtrlDispatcher(DispatchTable[0]);
end.
what can be wrong ?

runger 21. Jun 2005 13:31

Re: Why Cant Start A service.
 
Hallo,

ich nehm mal an, dass deine Muttersprache deutsch ist, soviele Fehler kann ein Engländer niemals machen.
Bitte formuliere das ganze in deutsch!

rainer

alcaeus 21. Jun 2005 13:37

Re: Why Cant Start A service.
 
Hello rainer,

Zitat:

Zitat von runger
ich nehm mal an, dass deine Muttersprache deutsch ist, soviele Fehler kann ein Engländer niemals machen.
Bitte formuliere das ganze in deutsch!

there are more localized versions of Delphi than just the German one. Therefore, it is easily possible that a French person would program with Delphi. However, English questions are accepted on this board to a certain extent, so I don't think there's a reason to go off like that.

@ZuBi: Are you sure that the problem is in the Code you posted? What does the installservice method do? I don't think that those 4 lines of code cause your service to crash :-?

Greetz
alcaeus

DP-Maintenance 21. Jun 2005 13:37

DP-Maintenance
 
Dieses Thema wurde von "alcaeus" von "Object-Pascal / Delphi-Language" nach "Windows API / MS.NET Framework API" verschoben.
Und ab zur WinAPI. Ist dort wohl besser aufgehoben.

ZuBi 21. Jun 2005 14:05

Re: Why Cant Start A service.
 
Zitat:

Zitat von alcaeus
Hello rainer,

Zitat:

Zitat von runger
ich nehm mal an, dass deine Muttersprache deutsch ist, soviele Fehler kann ein Engländer niemals machen.
Bitte formuliere das ganze in deutsch!

there are more localized versions of Delphi than just the German one. Therefore, it is easily possible that a French person would program with Delphi. However, English questions are accepted on this board to a certain extent, so I don't think there's a reason to go off like that.

@ZuBi: Are you sure that the problem is in the Code you posted? What does the installservice method do? I don't think that those 4 lines of code cause your service to crash :-?

Greetz
alcaeus

i quite sure the problem is in there, there for i debug it

Delphi-Quellcode:
FillChar(DispatchTable, SizeOf(DispatchTable), 0);
DispatchTable[0].lpServiceName:= PChar(S_Name);
DispatchTable[0].lpServiceProc:= @ServiceProc;
If not StartServiceCtrlDispatcher(DispatchTable[0]) Then AddToMessageLog('StartServiceCtrlDispatcher error');
Log:
Code:
[16:02:13] StartServiceCtrlDispatcher error
its seems its not passing this so the problem comes from there, i tryed to see if its somthing with ServiceProc but when i put there a log, its ont wrting anything so its not getting to there, i am trying to implent service in a dll( is it other method ? ).

i know its to know the problem from this few lines i have posted, there for i will post all soon.

Ps: It seems it cant register the proc (@ServiceProc) so it cant find the procedure, i dont know why.

[edit=alcaeus]Replaced code-tags with delphi-tags. Mfg, alcaeus[/edit]

Olli 23. Jun 2005 20:02

Re: Why Cant Start A service.
 
Zitat:

Zitat von ZuBi
i quite sure the problem is in there, there for i debug it

Delphi-Quellcode:
FillChar(DispatchTable, SizeOf(DispatchTable), 0);
DispatchTable[0].lpServiceName:= PChar(S_Name);
DispatchTable[0].lpServiceProc:= @ServiceProc;
If not StartServiceCtrlDispatcher(DispatchTable[0]) Then AddToMessageLog('StartServiceCtrlDispatcher error');

Straight from this code there's no obvious mistake!

Zitat:

Zitat von ZuBi
Log:
Code:
[16:02:13] StartServiceCtrlDispatcher error
its seems its not passing this so the problem comes from there, i tryed to see if its somthing with ServiceProc but when i put there a log, its ont wrting anything so its not getting to there,

So control is not passed to the SCM?

Zitat:

Zitat von ZuBi
i am trying to implent service in a dll( is it other method ? ).

I doubt that will work, since DLLs and PE/EXE files share only the structure but differ by many flags. The SCM was made to get control over an EXE file, not a DLL.

Zitat:

Zitat von ZuBi
i know its to know the problem from this few lines i have posted, there for i will post all soon.

Ps: It seems it cant register the proc (@ServiceProc) so it cant find the procedure, i dont know why.

Could you please add a GetLastError() after the IF-condition and tell us the error code?! There must be one.

ZuBi 30. Jun 2005 00:12

Re: Why Cant Start A service.
 
Zitat:

Zitat von Olli
Zitat:

Zitat von ZuBi
i quite sure the problem is in there, there for i debug it

Delphi-Quellcode:
FillChar(DispatchTable, SizeOf(DispatchTable), 0);
DispatchTable[0].lpServiceName:= PChar(S_Name);
DispatchTable[0].lpServiceProc:= @ServiceProc;
If not StartServiceCtrlDispatcher(DispatchTable[0]) Then AddToMessageLog('StartServiceCtrlDispatcher error');

Straight from this code there's no obvious mistake!

Zitat:

Zitat von ZuBi
Log:
Code:
[16:02:13] StartServiceCtrlDispatcher error
its seems its not passing this so the problem comes from there, i tryed to see if its somthing with ServiceProc but when i put there a log, its ont wrting anything so its not getting to there,

So control is not passed to the SCM?

Zitat:

Zitat von ZuBi
i am trying to implent service in a dll( is it other method ? ).

I doubt that will work, since DLLs and PE/EXE files share only the structure but differ by many flags. The SCM was made to get control over an EXE file, not a DLL.

Zitat:

Zitat von ZuBi
i know its to know the problem from this few lines i have posted, there for i will post all soon.

Ps: It seems it cant register the proc (@ServiceProc) so it cant find the procedure, i dont know why.

Could you please add a GetLastError() after the IF-condition and tell us the error code?! There must be one.

hello, the problem comes when trying to implent dll as service, it is possible and works at C. the SCM can control dll, as micrsoft doind it with loaders (svchost), there is no dubet the error comes when trying to reg the procedure, if i covert it to exe it works like it shuold, seince it dll and delphi doesnt speak with win like c, i tryd using stcall to make it like c, since nobody if its really works, its not. and i still cant make it as a service. the problem its possible becouse same thing works with c code posted artclie i saw some where. now can u sper few min and try slove it ? with code. u dont need alot just proc for install then to reg it(StartServiceCtrlDispatcher). if u want my codes let me know.

Olli 30. Jun 2005 09:06

Re: Why Cant Start A service.
 
Zitat:

Zitat von ZuBi
hello, the problem comes when trying to implent dll as service, it is possible and works at C. the SCM can control dll, as micrsoft doind it with loaders (svchost), there is no dubet the error comes when trying to reg the procedure, if i covert it to exe it works like it shuold, seince it dll and delphi doesnt speak with win like c, i tryd using stcall to make it like c, since nobody if its really works, its not. and i still cant make it as a service. the problem its possible becouse same thing works with c code posted artclie i saw some where. now can u sper few min and try slove it ? with code. u dont need alot just proc for install then to reg it(StartServiceCtrlDispatcher). if u want my codes let me know.

Thanks for the hint. You are right. MS uses this method (starting with W2K or WXP) to run different services in different instances of "svchost.exe".

Can you please post the link to the article (with C code). Maybe it will bring the enlightening moment ;) ... thanks.

ZuBi 1. Jul 2005 01:19

Re: Why Cant Start A service.
 
Zitat:

Zitat von Olli
Zitat:

Zitat von ZuBi
hello, the problem comes when trying to implent dll as service, it is possible and works at C. the SCM can control dll, as micrsoft doind it with loaders (svchost), there is no dubet the error comes when trying to reg the procedure, if i covert it to exe it works like it shuold, seince it dll and delphi doesnt speak with win like c, i tryd using stcall to make it like c, since nobody if its really works, its not. and i still cant make it as a service. the problem its possible becouse same thing works with c code posted artclie i saw some where. now can u sper few min and try slove it ? with code. u dont need alot just proc for install then to reg it(StartServiceCtrlDispatcher). if u want my codes let me know.

Thanks for the hint. You are right. MS uses this method (starting with W2K or WXP) to run different services in different instances of "svchost.exe".

Can you please post the link to the article (with C code). Maybe it will bring the enlightening moment ;) ... thanks.

i am sorry but the article is down atm or deleted i will tr y to find u
anyway here is a link might help http://support.microsoft.com/?kbid=314056

first u create a service, then spfic it to svchost, and add feild called servicedll that has your dll
after that u just make the service - < not works

ps. i will try to reserch it again.. couse i need it too i am days on it and nothing.

{
// Articles:
// 1. HOWTO Create a service dll used by svchost.exe by bingle, at: http://www.BingleSite.net/article/sv...l-service.html
// 2. Inside Win32 Services, Part 2 by: Mark Russinovich, at: http://www.winnetmag.com/Articles/In...leID=8943&pg=3
// 3. Platform SDK: Tools - Rundll32, at: http://msdn.microsoft.com/library/en...s/rundll32.asp

}

Olli 1. Jul 2005 10:18

Re: Why Cant Start A service.
 
The perhaps most interesting thing (which you did wrong as well) is, that you MUST NOT use StartServiceCtrlDispatcher(). Actually this function does nothing more than passing the dispatcher function address to the SCM. The SCM calls it and the service EXE is no more than a "quasi-DLL" of the SCM from this point.

So this was your first mistake. You don't need to call this function because it is only needed if your service was located in an EXE file!

... to be continued ...


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:11 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz