Share via


IObexDevice::Put (Windows CE 5.0)

Send Feedback

This method issues a Put command for an object that is passed to the server.This sends information to the remote device using a specific service.

HRESULT Put(IHeaderCollection* pHeaders,IStream** ppStream);

Parameters

  • pHeaders
    [in] Pointer to the headers collection that describes the object.
  • ppStream
    [in, out] Unique. Destination pointer to the IStream interface, which is used to write the data. For example, to send a file to a remote device, wrap the file around a steam and then put that stream on the remote device. This parameter initially returns an empty stream to be filled with the data to be transmitted.

Return Values

The appropriate HResult is returned.

Remarks

To verify the Put operation has completed, run IStream::Commit before you close the operation. This practice is particularly useful when deleting a file. A return of S_OK indicates the operation has completed successfully. Limit the stream size to manageable chunks of information (512 bytes, for example). Transferring very large streams of information prevent the ability to cancel the transfer of that information until the entire transfer process is complete.

The following code example shows how to delete a file after the put operation has completed. This example assumes the existence of an IObexDevice object that is named pObexDevice and is correctly initialized. It also assumes that an IHeaderCollection object, named pHeaderCollection, is initialized.

//
// A PUT operation that has BODY is assumed by the 
// server to be a delete  (per IrOBEX 1.2 spec section 3.3.3.6).
// This example demonstrates how to use the WinCE OBEX client 
// implementation to delete a file.

//
//  ---The construction/connection code of IObex/IObexDevice has been
//  omitted for brevity.
//

IStream *pStream = NULL;
if(FAILED(pHeaderCollection->AddName(L"MyFile.txt"))) 
   goto Error;
if(FAILED(pObexDevice->Put(pHeaderCollection, &pStream))) 
   goto Error;

// NOTE: If Commit fails, the delete operation was either 
// rejected by the server or the connection was lost. 
// In either case, the file deletion failed.

if(FAILED(pStream->Commit(0))) 
   goto Error;

//Success return.
hRet = S_OK;
goto Done;

Error:
    //Display Error and go to cleanup code.
    hRet = E_FAIL;
Done:
    //Clean up.

Requirements

Smartphone: Smartphone 2002 and later

Pocket PC: Pocket PC 2002 and later

OS Versions: Windows CE .NET 4.0 and later.

Header: Obex.h, Obex.idl.

Link Library: Uuid.lib.

See Also

Client Support | IObexDevice | IStream | OBEX Interfaces

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.