How to Start an Application at Boot Time Under Windows 95

Last reviewed: September 25, 1995
Article ID: Q125714
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows 95 version 4.0
    

SUMMARY

Windows NT supports a Win32-based application type known as a Service. A Service may be started at boot time, automatically, by a user with the Service Control Manager facility or by Win32-based applications that use the service-related Win32 APIs. The Service Control subsystem and the associated Win32 APIs are not supported in Windows 95. In place of services, Windows 95 has two registry keys that will allow users to run applications before a user logs in when the system first starts up.

MORE INFORMATION

Microsoft recognizes the value that Services and the Service Control manager have, therefore, we have implemented a smaller version of the Service Control Manager in Windows 95 so that applications can run before a user logs in. At boot time, the system checks two new registry keys: "RunServices" and "RunServicesOnce".

   HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion
      RunServices  [key]
         bubba95=service.exe /params [string value]

      ...

      RunServicesOnce  [key]

      ...

The value names are arbitrary. The value data is the command line passed to CreateProcess(). Values under the key RunServicesOnce are deleted after the application is launched. Because these applications are started before the user logs onto the system, the user has not been validated and the applications cannot assume that they have particular networking permissions enabled. Windows 95, unlike Windows NT, only has one security context for the entire system. Therefore, don't assume that any application that starts has access to a particular network resource because a particular user has access to this network resource.

Applications started by the RunServices and RunServicesOnce keys will be closed when the user selects "Close all programs and log on as a different user" from the Shutdown dialog on the Start Menu. A Win32-based application can prevent itself or any other Win32-based application from being closed when the user logs off by calling RegisterServiceProcess(). Win32-based applications registered in this manner close only when the system is shut down. However, the application must consider that different user can be logged on at different times during its execution. The application can distinguish between a user logging off and the system shutting down by examining the lParam of WM_QUERYENDSESSION and WM_ENDSESSION. If the system is being shut down, lParam is NULL. If the user is logging off, lParam is set to EWX_REALLYLOGOFF.

To access RegisterServiceProcess, retrieve a function pointer using GetProcAddress() on KERNEL32.DLL.

RegisterServiceProcess

DWORD RegisterServiceProcess(

    DWORD dwProcessId,   // process identifier
    DWORD dwServiceType  // type of service
   );

Parameters:
  • dwProcessId: Specifies the identifier of the process to register as a

          service process or NULL to register the current process. An
          application receives the process ID when it uses CreateProcess() to
          start the application.
    
  • dwServiceType: One of the following values:

       Define                    Value       Meaning
       RSP_SIMPLE_SERVICE        0x00000001  Registers the process as a
                                             simple service process.
    
       RSP_UNREGISTER_SERVICE    0x00000000  Unregisters the process as a
                                             service process.
    
    
Return Value:

The return value is 1 if successful or 0 if an error occurs.


Additional reference words: 3.95 4.00
KBCategory: kbprg
KBSubcategory: BseService


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 25, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.