Service.CreateNewObject method

The CreateNewObject method creates and initializes a WPDObject to the specified data format.

Syntax

retVal = Service.CreateNewObject(
  Format
)

Parameters

Format

String that is the data format of the new WPDObject.

Return value

Returns a Creation Container object that is used to set properties and data. When the Creation Container is passed to the Service.AddChild method, a new WPDObject containing the properties and data of the specified data format will be added as the child of a Service object.

Examples

The following JScript example uses the CreateNewObject method to add a newly created Service object (a WMA ringtone) as a child of another Service object. In this example, ringtone is the Creation Container that is used to set the property MediaTitle, and the ringtone data. When ringtone is added as a child of the ringtoneService object, it becomes a new WPDObject object that represents a ringtone on the device, and the property value and data are persisted.

// Get a WMA ringtone from a vendor.         
var request = new ActiveXObject("MSXML2.XMLHTTP.3.0");
request.open("GET", "https://vendor/site/ringtone.wma", false);
request.send();

// Create a new service object of the "Wma" format. Set its title,
// and set its data to the WMA ringtone obtained from the vendor.    
var ringtone = ringtonesService.CreateNewObject("Wma");  
ringtone.MediaTitle = "blues";
ringtone.Data = request.responseStream;

// Add the new service object as a child of the ringtoneService object.
// Note that the new object will not be persisted until it is added by
// using this method.    
ringtoneService.AddChild(ringtone);

Requirements

Minimum supported client
Windows 7 [desktop apps only]
Minimum supported server
Windows Server 2008 R2 [desktop apps only]

See also

Service Object

WPDObject