StrFromTimeIntervalA function

Converts a time interval, specified in milliseconds, to a string.

Syntax

int StrFromTimeIntervalA(
  PSTR  pszOut,
  UINT  cchMax,
  DWORD dwTimeMS,
  int   digits
);

Parameters

pszOut

Type: PTSTR

A pointer to a buffer that, when this function returns successfully, receives the converted number.

cchMax

Type: UINT

The size of pszOut, in characters. If cchMax is set to zero, StrFromTimeInterval will return the minimum size of the character buffer needed to hold the converted string. In this case, pszOut will not contain the converted string.

dwTimeMS

Type: DWORD

The time interval, in milliseconds.

digits

Type: int

The maximum number of significant digits to be represented in pszOut. Some examples are:

dwTimeMS digits pszOut
34000 3 34 sec
34000 2 34 sec
34000 1 30 sec
74000 3 1 min 14 sec
74000 2 1 min 10 sec
74000 1 1 min

Return Value

Type: int

Returns the number of characters in pszOut, excluding the terminating NULL character.

Remarks

The time value returned in pszOut will always be in the form hh hours mm minutes ss seconds. Times that exceed twenty four hours are not converted to days or months. Fractions of seconds are ignored.

Examples

C++
#include <windows.h>
#include <iostream.h>
#include "Shlwapi.h"

void main(void) { char TimeString[256]; char *pszOut; pszOut = TimeString;

cout &lt;&lt; "The return value from the call to"
     &lt;&lt; "\nthe function StrFromTimeInterval will"
     &lt;&lt; "\nreturn the number of elements in the buffer: " &lt;&lt; endl;

cout &lt;&lt; "\nThe return from StrFromTimeInterval is " 
     &lt;&lt; StrFromTimeInterval(pszOut,30, 34000,30);

cout &lt;&lt; "\nThe contents of the TimeString Buffer " &lt;&lt; pszOut &lt;&lt; endl;

cout &lt;&lt; "The return from StrFromTimeInterval is " 
     &lt;&lt; StrFromTimeInterval(pszOut,30, 74000,3);

cout &lt;&lt; "\nThe contents of the TimeString Buffer " &lt;&lt; pszOut &lt;&lt; endl;

cout &lt;&lt; "The return from StrFromTimeInterval is " 
     &lt;&lt; StrFromTimeInterval(pszOut,30, 74000,2);

cout &lt;&lt; "\nThe contents of the TimeString Buffer " &lt;&lt; pszOut &lt;&lt; endl;

cout &lt;&lt; "The return from StrFromTimeInterval is " 
     &lt;&lt; StrFromTimeInterval(pszOut,30, 74000,1)
     &lt;&lt; "\nThe contents of the TimeString Buffer " &lt;&lt; pszOut &lt;&lt; endl;

}

OUTPUT:


The return value from the call to the function StrFromTimeInterval will return the number of elements in the buffer:

The return from StrFromTimeInterval is 7 The contents of the TimeString Buffer 34 sec The return from StrFromTimeInterval is 13 The contents of the TimeString Buffer 1 min 14 sec The return from StrFromTimeInterval is 13 The contents of the TimeString Buffer 1 min 10 sec The return from StrFromTimeInterval is 6 The contents of the TimeString Buffer 1 min

Requirements

   
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlwapi.h
Library Shlwapi.lib
DLL Shlwapi.dll (version 4.71 or later)