Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
For Windows Mobile:
Services.exe supports the IOCTL_SERVICE_COMMAND_LINE_PARAMS IOCTL for handling command line parameters. This IOCTL can be used to indicate that a set of command-line arguments are being passed to the service from the command-line tool.
For example, a user could type the following information using
the Services.exe command line tool:
"services command HTP0: Arg1 Arg2 Arg3"
. The command
string indicates that a set of arguments follows after the service
instance name (
HTP0:
). Services.exe should pass these arguments
directly to the service's
xxx_IOControl
(Services.exe)function.
The Services.exe command-line tool is particularly useful for applications that have only few configuration options and do not require a separate application to configure them.
The following example shows how to print out each command line argument to a debug output window and displays a "Mission accomplished" message.
Copy Code | |
---|---|
xxx_IOControl(....) { case IOCTL_SERVICE_COMMAND_LINE_PARAMS: { ServicesExeCommandLineParams *pCmdLine = (ServicesExeCommandLineParams*) pBufIn; DEBUGMSG(1,(L"xxx_IOCTL got IOCTL_SERVICE_COMMAND_LINE_PARAMS, # args = %d\r\n",pCmdLine->dwArgs)); for (DWORD i = 0; i < pCmdLine->dwArgs; i++) { DEBUGMSG(1,(L" xxx_IOCTL arg %d = %s\r\n",i,pCmdLine->ppwszArgs[i])); } WCHAR *szBuf = (WCHAR*)pBufOut; DEBUGCHK(szBuf[0] == 0); wsprintf(szBuf,L"Mission accomplished!!!"); return TRUE; } break; } |
Note: |
---|
In the past, some services have used the parameters of xxx_IOControlincorrectly. For example, some services have used the pBufInparameter to pass a 32-bit DWORD value instead of a pointer. Services.exe no longer supports this incorrect usage. Before calling into your service, services.exe will now perform extra checks to make sure that the 32-bit value is a legal pointer. If the value for pBufInis not legal, services.exe will not call xxx_IOControl. |