StrFromTimeIntervalW 関数 (shlwapi.h)

ミリ秒単位で指定された時間間隔を文字列に変換します。

構文

int StrFromTimeIntervalW(
  [out] PWSTR pszOut,
        UINT  cchMax,
        DWORD dwTimeMS,
        int   digits
);

パラメーター

[out] pszOut

種類: PTSTR

この関数が正常に返されると、変換された数値を受け取るバッファーへのポインター。

cchMax

型: UINT

pszOut のサイズ (文字単位)。 cchMax が 0 に設定されている場合、StrFromTimeInterval は、変換された文字列を保持するために必要な文字バッファーの最小サイズを返します。 この場合、 pszOut には変換された文字列は含まれません。

dwTimeMS

型: DWORD

時間間隔 (ミリ秒単位)。

digits

型: int

pszOut で表される有効桁数の最大数。 いくつかの例を次に示します。

dwTimeMS 数値 pszOut
34000 3 34 秒
34000 2 34 秒
34000 1 30 秒
74000 3 1 分 14 秒
74000 2 1 分 10 秒
74000 1 1 分

戻り値

型: int

終端の NULL 文字を除き、pszOut 内の文字数を返します。

注釈

pszOut で返される時間値は、常に hh hours mm minutes 秒の形式になります。 24 時間を超える時間は、日または月に変換されません。 秒の分数は無視されます。

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

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

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

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

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

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

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

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

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

    cout << "The return from StrFromTimeInterval is " 
         << StrFromTimeInterval(pszOut,30, 74000,1)
         << "\nThe contents of the TimeString Buffer " << pszOut << 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

Note

shlwapi.h ヘッダーは、STRFromTimeInterval をエイリアスとして定義します。このエイリアスは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI または Unicode バージョンを自動的に選択します。 encoding-neutral エイリアスの使用を encoding-neutral ではないコードと混在すると、コンパイル エラーまたはランタイム エラーが発生する不一致が発生する可能性があります。 詳細については、「 関数プロトタイプの規則」を参照してください。

要件

要件
サポートされている最小のクライアント Windows 2000 Professional、Windows XP [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー shlwapi.h
Library Shlwapi.lib
[DLL] Shlwapi.dll (バージョン 4.71 以降)