SmsCalculateMessageFragments (Compact 2013)

3/26/2014

This function calculates the number of fragments that the text message will be divided into when it is sent out to the network.

Syntax

HRESULT  SmsCalculateMessageFragments(
    const DWORD dwRadioIndex,
    const LPCTSTR ptsMessageProtocol,
    const WCHAR * const pszInputMsg,
    const DWORD cchMsgLength,
    const SMS_DATA_ENCODING smsdeOutputEncoding,
    DWORD * const pdwTotalOutputSize,
    DWORD * const pdwTotalFragmentCount,
    DWORD * const pdwMaxSingleFragmentSize,
    DWORD * const pdwMaxMultipartFragmentSize,
    SMS_DATA_ENCODING * const psmsdeActualOutputEncoding
);

Parameters

  • dwRadioIndex
    [in] The index of the radio to use for this Short Message Service (SMS) communication session.
  • pszInputMsg
    [in] The message to send.
  • cchMsgLength
    [in] The length in characters of pszInputMsg.
  • smsdeOutputEncoding
    [in] The preferred output encoding of the message.
  • pdwTotalOutputSize
    [in] A pointer to a storage location to place the output.

    [out] The total number of bytes used by all the message fragments used to send the message.

  • pdwTotalFragmentCount
    [in] A pointer to a storage location to place the output.

    [out] The number of fragments the message will be split into.

  • pdwMaxSingleFragmentSize
    [in] A pointer to a storage location to place the output.

    [out] If pdwTotalFragmentCount=1, the number of bytes used to send the message.

  • pdwMaxMultipartFragmentSize
    [in] A pointer to a storage location to place the output.

    [out] If pdwTotalFragmentCount>1, the number of bytes of the longest fragment used to send the message.

  • psmsdeActualOutputEncoding
    [in] A pointer to a storage location to place the output.

    [out] The encoding that will be used to send the SMS. Different from smsdeOutputEncoding when the preferred encoding is not available.

Return Value

HRESULT is S_OK for success, a standard error value, or one of the error constants defined in SMS Specific Errors.

pdwMaxSingleFragmentSize and pdwMaxMultipartFragmentSize are always returned; however, pdwMaxSingleFragmentSize is only useful when pdwTotalFragmentCount=1 and pdwMaxMultipartFragmentSize is only useful when pdwTotalFragmentCount>1.

Example

HRESULT           hr          ;
SMS_HANDLE        smshHandle  ;

// input
int               RADIO_INDEX_1 = 1;
TCHAR*            ptszSendMsg     ; 

// output
DWORD             dwTotalOutputSize          ;
DWORD             dwTotalFragmentCount       ;
DWORD             dwMaxSingleFragmentSize    ;
DWORD             dwMaxMultipartFragmentSize ;
SMS_DATA_ENCODING smsdeActualOutputEncoding  ;
    
// setup
ptszSendMsg     = TEXT("TESTING");

hr = SmsOpen( SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, 0 );
    
hr = SmsCalculateMessageFragments(
         RADIO_INDEX_1
       , SMS_MSGTYPE_TEXT
       , ptszSendMsg 
       , _tcslen( ptszSendMsg )
       , SMSDE_OPTIMAL
       , &dwTotalOutputSize
       , &dwTotalFragmentCount
       , &dwMaxSingleFragmentSize
       , &dwMaxMultipartFragmentSize
       , &smsdeActualOutputEncoding
       );

hr = SmsClose( smshHandle );

Remarks

pszInputMsg may be NULL.

When pszInputMsg is NULL and cchMsgLength is zero, this function returns pdwMaxSingleFragmentSize, pdwMaxMultipartFragmentSize, and psmsdeActualOutputEncoding according to smsdeOutputEncoding.

E_INVALIDARG is returned when pszInputMsg is NULL and cchMsgLength is not zero.

Requirements

Header

sms.h

Library

sms.lib

See Also

Reference

Short Message Service Functions
SmsOpen
SmsClose
SMS Message Mode Constants

Other Resources

WaitForSingleObject
MsgWaitForMultipleObjects
SetEvent
ResetEvent
CloseHandle