How to pass a parameter to a windows service once and for all at install instead of each start

前端 未结 8 2071
南旧
南旧 2020-12-09 04:13

We have a Windows Service application that can accept command line parameters like:

MyService -option 

So far, when we want to start the

8条回答
  •  轮回少年
    2020-12-09 04:31

    Arguments passed on the command-line via ImagePath are accessible in main() or via GetCommandLine(). You could install with command-line args and then in your ServiceMain, check to see if any arguments were passed in the lpszArgs parameter. If not, call GetCommandLine and see if any were passed that way.

提交回复
热议问题