@@ -17,6 +17,7 @@ class TestInstance :
1717 m_properties (list.begin(), list.end()),
1818 m_ulRef (1 )
1919 {
20+ m_locale = ::_wcreate_locale (LC_ALL, L" en-US" );
2021 }
2122
2223 TestInstance (
@@ -27,6 +28,8 @@ class TestInstance :
2728 m_properties (properties),
2829 m_ulRef (1 )
2930 {
31+ m_locale = ::_wcreate_locale (LC_ALL, L" en-US" );
32+
3033 for (const auto package : packages)
3134 {
3235 m_packages.push_back (package);
@@ -35,6 +38,10 @@ class TestInstance :
3538
3639 ~TestInstance ()
3740 {
41+ if (m_locale)
42+ {
43+ ::_free_locale (m_locale);
44+ }
3845 }
3946
4047 // IUnknown
@@ -191,7 +198,7 @@ class TestInstance :
191198 _Out_ InstanceState* pState
192199 )
193200 {
194- return TryGetLONGLONG (L" State" , reinterpret_cast <PLONGLONG >(pState));
201+ return TryGetULONG (L" State" , reinterpret_cast <PULONG >(pState));
195202 }
196203
197204 STDMETHODIMP GetPackages (
@@ -414,9 +421,9 @@ class TestInstance :
414421 return hr;
415422 }
416423
417- STDMETHODIMP TryGetLONGLONG (_In_ LPCWSTR wszName, _Out_ PLONGLONG pll )
424+ STDMETHODIMP TryGetULONG (_In_ LPCWSTR wszName, _Out_ PULONG pul )
418425 {
419- if (!pll )
426+ if (!pul )
420427 {
421428 return E_POINTER;
422429 }
@@ -426,10 +433,10 @@ class TestInstance :
426433 auto hr = TryGet (wszName, value);
427434 if (SUCCEEDED (hr))
428435 {
429- *pll = _wtoi64 (value.c_str ());
430- if (*pll == 0 )
436+ *pul = _wcstoul_l (value.c_str (), NULL , 10 , m_locale );
437+ if (*pul == 0 || *pul == ULONG_MAX )
431438 {
432- if (errno == ERANGE || errno == EINVAL )
439+ if (errno == ERANGE)
433440 {
434441 hr = E_INVALIDARG;
435442 }
@@ -444,5 +451,6 @@ class TestInstance :
444451 MapType m_properties;
445452 TestPropertyStore m_catalogProperties;
446453 TestPropertyStore m_additionalProperties;
454+ _locale_t m_locale;
447455 ULONG m_ulRef;
448456};
0 commit comments