in Win32TestApp/Win32TestApp.cpp [52:133]
int main()
{
HINSTANCE dllHandle = NULL;
WindowsStorePtr storePtr = nullptr;
WindowsStoreErrorType result = WINRT_NO_ERROR;
//Load the WindowsStore dll
#ifdef USING_APP_MANIFEST
if (windows10orGreaterWithManifest())
{
dllHandle = LoadLibrary(L"WindowsStore.dll");
}
#else
if (windows10orGreater())
{
dllHandle = LoadLibrary(L"WindowsStore.dll");
}
#endif
if (NULL == dllHandle)
{
std::cout << "Unable to load WindowsStore.dll" << std::endl;
goto cleanup;
}
// Get WindowsStore DLL function pointers. Error checking needs to be added!
gWindowsStoreInitFunc = reinterpret_cast<WindowsStoreInitializeFunc>(::GetProcAddress(dllHandle, "store_initialize"));
gWindowsStorePurchaseFunc = reinterpret_cast<WindowsStorePurchaseFunc>(::GetProcAddress(dllHandle, "store_purchase"));
gWindowsStoreLicenseStateFunc = reinterpret_cast<WindowsStoreLicenseStateFunc>(::GetProcAddress(dllHandle, "store_license_state"));
gWindowsStoreGetPriceFunc = reinterpret_cast<WindowsStoreGetPriceFunc>(::GetProcAddress(dllHandle, "store_get_price"));
gWindowsStoreFreeFunc = reinterpret_cast<WindowsStoreFreeFunc>(::GetProcAddress(dllHandle, "store_free"));
// initialize Windows Store functionality
result = gWindowsStoreInitFunc(&storePtr, GetConsoleWindow(), storeLicenseStateChangedCallback, nullptr);
if (result != WINRT_NO_ERROR)
{
std::cout << "Cannot initialize Windows Store." << std::endl;
switch (result)
{
case WINRT_WINDOWS_RUNTIME_ERROR:
std::cout << "Unable to initialize Windows Runtime" << std::endl;
break;
case WINRT_WINDOWS_VERSION_ERROR:
std::cout << "This version of Windows does not support Windows::Services::Store" << std::endl;
break;
case WINRT_APP_PACKAGE_ERROR:
std::cout << "This app is not running inside of an App Package" << std::endl;
break;
default:
std::cout << "Unable to initialize Windows Store" << std::endl;
break;
}
goto cleanup;
}
// get Windows Store trial license info
gWindowsStoreGetPriceFunc(storePtr, storeGetPriceCallback, nullptr);
gWindowsStoreLicenseStateFunc(storePtr, storeLicenseStateCallback, nullptr);
gWindowsStorePurchaseFunc(storePtr, storePurchaseCallback, nullptr);
cleanup:
// wait for user to exit...
std::cout << "Press any key to exit..." << std::endl;
char c = _getch();
// release the WindowsStore object
if (gWindowsStoreFreeFunc)
{
gWindowsStoreFreeFunc(storePtr);
}
//Free the library:
if (dllHandle)
{
FreeLibrary(dllHandle);
}
return 0;
}