Compartir a través de


Handling Command Line Parameters (Windows CE 5.0)

Send Feedback

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.

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_IOControl incorrectly. For example, some services have used the pBufIn parameter 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 pBufIn is not legal, services.exe will not call xxx_IOControl.

See Also

Services.exe | Using Services.exe from the Command Line

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.