CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 1999
    Posts
    36

    Passing Parameters to Win32 Services

    Hi,

    How one can pass the parameters to the Win32 service? There are ways like passing it in StartService option or mentioning the startup parmeters in Service Control Pallete. But in my case the requirement is that whenever system restarts my service reads those parameters (that are passed to it) and start itself?

    I have found at many places to mention the parameters in the registry (HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/...) and I tried that also but in any case I am unable to pass the parameter to the service.

    Can some one please explain to me clearly we can pass parameters to the service via registry?

    As far as I know these parameters will be passed to servicemain function by the OS.If I am wrong please correct me.

    With Warm Regards
    Somu

  2. #2
    Join Date
    Sep 2002
    Location
    Romania
    Posts
    67
    I've had same problem. You can do this in the folowing way: create a subkey (ex:HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Your_service/params ) and set values (in that subkey) for the parameters. When the service start check the command line (ServiceMain arguments) and if it has arguments use those arguments and save their values in the corresponding values; if not open the subkey and use saved parameters.

  3. #3
    Join Date
    Aug 1999
    Posts
    36
    This implies that I will have to read parameters given in registry myself and OS will not read them and pass them to ServiceMain function().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured