AddCommasExportW

Go to Home Page

Adds grouping to a number according to the current users regional settings

Syntax

LPWSTR WINAPI AddCommasExportW (
    DWORD value,
    LPWSTR pwszBuf
)

Parameters

value
The number to format
pwszBuf
A pointer to the converted string. The length of the string buffer is assumed to be 36863 (0x8fff) characters by the function.

Return Value

The buffer value

Remarks

Even though the function assumes a buffer length of 0x8fff characters, it is practically impossible for the converted string to be that length.

This function was also known as AddCommasW/_AddCommasW@8 in NT4 and 2000.

Example

#include <windows.h>
#include <iostream>
typedef LPWSTR (CALLBACK*pfnAddCommasExportW)(DWORD, LPWSTR);

int __cdecl main()
{
    HMODULE hShell = LoadLibraryW(L"shell32.dll");
    pfnAddCommasExportW addCommasExportW = (pfnAddCommasExportW)GetProcAddress(hShell, (LPSTR)203);
    WCHAR buf[90] = {0};
    std::wcout << L"AddCommasExportW(90) = " << addCommasExportW(90, buf) << L'\n';
    std::wcout << L"AddCommasExportW(900) = " << addCommasExportW(900, buf) << L'\n';
    std::wcout << L"AddCommasExportW(9000) = " << addCommasExportW(9000, buf) << L'\n';
    std::wcout << L"AddCommasExportW(90000) = " << addCommasExportW(90000, buf) << L'\n';
    std::wcout << L"AddCommasExportW(900000) = " << addCommasExportW(900000, buf) << L'\n';
    std::wcout << L"AddCommasExportW(9000000) = " << addCommasExportW(9000000, buf) << L'\n';
    std::wcout << L"AddCommasExportW(90000000) = " << addCommasExportW(90000000, buf) << L'\n';
    FreeLibrary(hShell);
}
OUTPUT
------
AddCommasExportW(90) = 90
AddCommasExportW(900) = 900
AddCommasExportW(9000) = 9,000
AddCommasExportW(90000) = 90,000
AddCommasExportW(900000) = 900,000
AddCommasExportW(9000000) = 9,000,000
AddCommasExportW(90000000) = 90,000,000