Damn Microsoft, damn documents, damn ExecuteCommand

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.