<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[hilfe beim proggen von einem service]]></title><description><![CDATA[<p>könnt ihr mir bitte helfen ich bin dabei ein service zumachen aber finde den fehler net <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winuser.h&gt;
#include &lt;stdio.h&gt;
#include &lt;time.h&gt;

SERVICE_STATUS_HANDLE hStatus;
SERVICE_STATUS status;

char Service[]=&quot;MyService&quot;;

void WINAPI ServiceCtrlHandler( DWORD control )
{

    switch( control )
    {
    case SERVICE_CONTROL_SHUTDOWN:

    case SERVICE_CONTROL_STOP:
        // do shutdown stuff here

        status.dwCurrentState = SERVICE_STOPPED;
        status.dwWin32ExitCode = 0;
        status.dwCheckPoint = 0;
        status.dwWaitHint = 0;
        break;
    case SERVICE_CONTROL_INTERROGATE:
        // just set the current state to whatever it is...
        break;
    }

    ::SetServiceStatus( hStatus, &amp;status );
}

void WINAPI ServiceStart( DWORD numArgs, char **args )
{
    // we have to initialize the service-specific stuff
    memset( &amp;status, 0, sizeof(SERVICE_STATUS) );
    status.dwServiceType = SERVICE_WIN32;
    status.dwCurrentState = SERVICE_START_PENDING;
    status.dwControlsAccepted = SERVICE_ACCEPT_STOP;

    hStatus = ::RegisterServiceCtrlHandler( &quot;MyService&quot;, &amp;ServiceCtrlHandler );

    // more initialization stuff here

    ::SetServiceStatus( hStatus, &amp;status );
}

int create_theservice(char to[200])
{
    SC_HANDLE handle = ::OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );

	if( handle == NULL )
	{
		MessageBox(NULL,&quot;Could not connect to SCM dataase&quot;,0,0 );

	}

    SC_HANDLE service = ::CreateService(
    handle,
    Service,
    Service,
    GENERIC_READ | GENERIC_EXECUTE,
    SERVICE_WIN32_OWN_PROCESS,
    SERVICE_AUTO_START,
    SERVICE_ERROR_IGNORE,
    to,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
    );
    if( service == NULL )
	{
		if( ::GetLastError() != ERROR_SERVICE_EXISTS )
			     MessageBox(NULL,&quot;fehler beim machen vom service&quot;,0,0);  

    }
}
int start()
{
      SERVICE_TABLE_ENTRY dispatchTable[] =
      {
        { Service, &amp;ServiceStart },
        { NULL, NULL }
      };
    StartServiceCtrlDispatcher( dispatchTable );

}
int make_service()
{         
    DWORD  dw,test;
    char  to[200]=&quot;C:\\myservice.exe&quot;;
    create_theservice(to);
    start();
}
</code></pre>
<p>ach ja da gibts immern fehler:<br />
ERROR_FAILED_SERVICE_CONTROLLER_CONNECT</p>
<p>schon mal danke im voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/65245/hilfe-beim-proggen-von-einem-service</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 15:05:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/65245.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Feb 2004 20:14:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Tue, 17 Feb 2004 20:14:45 GMT]]></title><description><![CDATA[<p>könnt ihr mir bitte helfen ich bin dabei ein service zumachen aber finde den fehler net <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winuser.h&gt;
#include &lt;stdio.h&gt;
#include &lt;time.h&gt;

SERVICE_STATUS_HANDLE hStatus;
SERVICE_STATUS status;

char Service[]=&quot;MyService&quot;;

void WINAPI ServiceCtrlHandler( DWORD control )
{

    switch( control )
    {
    case SERVICE_CONTROL_SHUTDOWN:

    case SERVICE_CONTROL_STOP:
        // do shutdown stuff here

        status.dwCurrentState = SERVICE_STOPPED;
        status.dwWin32ExitCode = 0;
        status.dwCheckPoint = 0;
        status.dwWaitHint = 0;
        break;
    case SERVICE_CONTROL_INTERROGATE:
        // just set the current state to whatever it is...
        break;
    }

    ::SetServiceStatus( hStatus, &amp;status );
}

void WINAPI ServiceStart( DWORD numArgs, char **args )
{
    // we have to initialize the service-specific stuff
    memset( &amp;status, 0, sizeof(SERVICE_STATUS) );
    status.dwServiceType = SERVICE_WIN32;
    status.dwCurrentState = SERVICE_START_PENDING;
    status.dwControlsAccepted = SERVICE_ACCEPT_STOP;

    hStatus = ::RegisterServiceCtrlHandler( &quot;MyService&quot;, &amp;ServiceCtrlHandler );

    // more initialization stuff here

    ::SetServiceStatus( hStatus, &amp;status );
}

int create_theservice(char to[200])
{
    SC_HANDLE handle = ::OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );

	if( handle == NULL )
	{
		MessageBox(NULL,&quot;Could not connect to SCM dataase&quot;,0,0 );

	}

    SC_HANDLE service = ::CreateService(
    handle,
    Service,
    Service,
    GENERIC_READ | GENERIC_EXECUTE,
    SERVICE_WIN32_OWN_PROCESS,
    SERVICE_AUTO_START,
    SERVICE_ERROR_IGNORE,
    to,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
    );
    if( service == NULL )
	{
		if( ::GetLastError() != ERROR_SERVICE_EXISTS )
			     MessageBox(NULL,&quot;fehler beim machen vom service&quot;,0,0);  

    }
}
int start()
{
      SERVICE_TABLE_ENTRY dispatchTable[] =
      {
        { Service, &amp;ServiceStart },
        { NULL, NULL }
      };
    StartServiceCtrlDispatcher( dispatchTable );

}
int make_service()
{         
    DWORD  dw,test;
    char  to[200]=&quot;C:\\myservice.exe&quot;;
    create_theservice(to);
    start();
}
</code></pre>
<p>ach ja da gibts immern fehler:<br />
ERROR_FAILED_SERVICE_CONTROLLER_CONNECT</p>
<p>schon mal danke im voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/461571</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/461571</guid><dc:creator><![CDATA[gogoJohn]]></dc:creator><pubDate>Tue, 17 Feb 2004 20:14:45 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Wed, 18 Feb 2004 11:37:30 GMT]]></title><description><![CDATA[<p>kann mir niemand helfen???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/461951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/461951</guid><dc:creator><![CDATA[gogoJohn]]></dc:creator><pubDate>Wed, 18 Feb 2004 11:37:30 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Wed, 18 Feb 2004 11:48:11 GMT]]></title><description><![CDATA[<p>gogoJohn schrieb:</p>
<blockquote>
<p>ach ja da gibts immern fehler:</p>
</blockquote>
<p>Wo ist 'da'?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/461962</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/461962</guid><dc:creator><![CDATA[-King-]]></dc:creator><pubDate>Wed, 18 Feb 2004 11:48:11 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Wed, 18 Feb 2004 12:15:31 GMT]]></title><description><![CDATA[<p>beim starten</p>
<pre><code class="language-cpp">int start()
{
      SERVICE_TABLE_ENTRY dispatchTable[] =
      {
        { Service, &amp;ServiceStart },
        { NULL, NULL }
      };
    //des returnd immer ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 

    StartServiceCtrlDispatcher( dispatchTable );

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/461983</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/461983</guid><dc:creator><![CDATA[gogoJohn]]></dc:creator><pubDate>Wed, 18 Feb 2004 12:15:31 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Wed, 18 Feb 2004 12:35:25 GMT]]></title><description><![CDATA[<p>Aha. Dann mach erstmal das '&amp;' vor ServiceStart in der Initialisierung Deiner Service-Table weg. Und dann schliesse die Handles in create_theservice wieder (2x CloseServiceHandle).</p>
<p>Startest Du die Exe eigentlich selbst, oder machst Du das aus dem MMC Snap-In 'Dienste' heraus?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/462013</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/462013</guid><dc:creator><![CDATA[-King-]]></dc:creator><pubDate>Wed, 18 Feb 2004 12:35:25 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Wed, 18 Feb 2004 13:04:06 GMT]]></title><description><![CDATA[<p>nee gibt immer nochn fehler</p>
<p>ich wills so starten von der exe und beim autostart müssts ja automatissch geöfnet werden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/462040</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/462040</guid><dc:creator><![CDATA[gogoJohn]]></dc:creator><pubDate>Wed, 18 Feb 2004 13:04:06 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Wed, 18 Feb 2004 14:35:48 GMT]]></title><description><![CDATA[<p>gogoJohn schrieb:</p>
<blockquote>
<p>ich wills so starten von der exe und beim autostart müssts ja automatissch geöfnet werden</p>
</blockquote>
<p>??? Offensichtlich spreche ich Deine Sprache nicht und kann nur ahnen, was gemeint ist. Tipp: Starte den Service aus der MMC.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/462135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/462135</guid><dc:creator><![CDATA[-King-]]></dc:creator><pubDate>Wed, 18 Feb 2004 14:35:48 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Wed, 18 Feb 2004 14:38:41 GMT]]></title><description><![CDATA[<p>ja des geht nich da kommt dann immer</p>
<p>Fehler 1053 Der Dienst antwortet nicht rechtzeitig auf die Start- oder Steuerungsanfoderung</p>
]]></description><link>https://www.c-plusplus.net/forum/post/462141</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/462141</guid><dc:creator><![CDATA[gogoJohn]]></dc:creator><pubDate>Wed, 18 Feb 2004 14:38:41 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Wed, 18 Feb 2004 16:25:30 GMT]]></title><description><![CDATA[<p>hilft des was????</p>
]]></description><link>https://www.c-plusplus.net/forum/post/462293</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/462293</guid><dc:creator><![CDATA[gogoJohn]]></dc:creator><pubDate>Wed, 18 Feb 2004 16:25:30 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Thu, 19 Feb 2004 11:41:21 GMT]]></title><description><![CDATA[<p>weiß niemand wieso des nich geht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/463003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/463003</guid><dc:creator><![CDATA[gogoJohn]]></dc:creator><pubDate>Thu, 19 Feb 2004 11:41:21 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Thu, 19 Feb 2004 12:28:35 GMT]]></title><description><![CDATA[<p>hi,<br />
schau mal da:<br />
<a href="http://www.gamedev.net/reference/articles/article1899.asp" rel="nofollow">http://www.gamedev.net/reference/articles/article1899.asp</a><br />
vielleicht hilft dir das etwas weiter....</p>
<p>cu surf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/463068</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/463068</guid><dc:creator><![CDATA[surf.]]></dc:creator><pubDate>Thu, 19 Feb 2004 12:28:35 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Thu, 19 Feb 2004 12:46:48 GMT]]></title><description><![CDATA[<p>des hab fast 1 zu 1 kopiert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>aber trozdem danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/463091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/463091</guid><dc:creator><![CDATA[gogoJohn]]></dc:creator><pubDate>Thu, 19 Feb 2004 12:46:48 GMT</pubDate></item><item><title><![CDATA[Reply to hilfe beim proggen von einem service on Thu, 19 Feb 2004 12:51:24 GMT]]></title><description><![CDATA[<p>hast du auch eine main-Funktion (dort steht in den SDK Beispielen, das, was bei dir in start steht)<br />
Ansonsten schau dich mal im SDK unter <a href="http://msdn.microsoft.com/library/en-us/dllproc/base/services.asp" rel="nofollow">Services</a> etwas um <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/463097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/463097</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Thu, 19 Feb 2004 12:51:24 GMT</pubDate></item></channel></rss>