I wrote a WinService and want to use the control interface to control services other than STOP and START, such as executing related commands.
When using ServiceController, we found that only one ExecuteCommand method can be used for control and processing, while the damn ExecuteCommand only has one int type parameter to pass. Damn it !!!
Int: int. I want to use a 32-bit int for segment processing to implement the need to pass complex commands. If the damn ExecuteCommand does not work, the following error is reported:
System. InvalidOperationException: unable to control the MyWinService on the computer. ---> System. ComponentModel. Win32Exception: the parameter is incorrect.
--- End of the internal exception stack trace ---
In System. ServiceProcess. ServiceController. ExecuteCommand (Int32 command)
When I read the document, I am dizzy. I clearly stated that it is an int type and I passed it. Why is the parameter incorrect?
Hey, I guess whether the int type parameter is too large, so I tested the traversal of the parameters from-100 to + 100. The results are still different, causing a headache.
Fortunately, some colleagues are searching for materials at the same time. The answer is: the parameter value cannot be less than 128 or greater than 255.
Dizzy again !!!
Damn Microsoft, damn documents, damn ExecuteCommand