' ########################################################################################
' Microsoft Windows
' File: Ratings.inc
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
'#pragma once
#IF NOT %DEF(PBX_Ratings_PBI)
#DEFINE PBX_Ratings_PBI
%EQUATE `RATINGS_INC = 1
#INCLUDE ONCE "Legacy/Platform/WinError.inc"
#INCLUDE ONCE "Legacy/System/Shlwapi.inc"
DECLARE FUNCTION RatingEnable LIB "msrating.dll" ALIAS "RatingEnable" ( BYVAL hwndParent AS QUAD , BYREF pszUsername AS ASCIIZ , BYVAL fEnable AS LONG ) AS LONG
DECLARE FUNCTION RatingEnableW LIB "msrating.dll" ALIAS "RatingEnableW" ( BYVAL hwndParent AS QUAD
 , BYREF pszUsername AS WSTRINGZ
 , BYVAL fEnable AS LONG
 ) AS LONG
DECLARE FUNCTION RatingCheckUserAccess LIB "msrating.dll" ALIAS "RatingCheckUserAccess" ( BYREF pszUsername AS ASCIIZ
 , BYREF pszURL AS ASCIIZ
 , BYREF pszRatingInfo AS ASCIIZ
 , BYVAL pData AS BYTE PTR
 , BYVAL cbData AS DWORD
 , BYREF ppRatingDetails AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingCheckUserAccessW LIB "msrating.dll" ALIAS "RatingCheckUserAccessW" ( BYREF pszUsername AS WSTRINGZ
 , BYREF pszURL AS WSTRINGZ
 , BYREF pszRatingInfo AS WSTRINGZ
 , BYVAL pData AS BYTE PTR
 , BYVAL cbData AS DWORD
 , BYREF ppRatingDetails AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingAccessDeniedDialog LIB "msrating.dll" ALIAS "RatingAccessDeniedDialog" ( BYVAL hDlg AS DWORD
 , BYREF pszUsername AS ASCIIZ
 , BYREF pszContentDescription AS ASCIIZ
 , BYREF pRatingDetails AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingAccessDeniedDialogW LIB "msrating.dll" ALIAS "RatingAccessDeniedDialogW" ( BYVAL hDlg AS DWORD
 , BYREF pszUsername AS WSTRINGZ
 , BYREF pszContentDescription AS WSTRINGZ
 , BYREF pRatingDetails AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingAccessDeniedDialog2 LIB "msrating.dll" ALIAS "RatingAccessDeniedDialog2" ( BYVAL hDlg AS DWORD
 , BYREF pszUsername AS ASCIIZ
 , BYREF pRatingDetails AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingAccessDeniedDialog2W LIB "msrating.dll" ALIAS "RatingAccessDeniedDialog2W" ( BYVAL hDlg AS DWORD
 , BYREF pszUsername AS WSTRINGZ
 , BYREF pRatingDetails AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingFreeDetails LIB "msrating.dll" ALIAS "RatingFreeDetails" ( BYVAL pRatingDetails AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingObtainCancel LIB "msrating.dll" ALIAS "RatingObtainCancel" ( BYVAL hRatingObtainQuery AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingObtainQuery LIB "msrating.dll" ALIAS "RatingObtainQuery" ( BYREF pszTargetUrl AS ASCIIZ
 , BYVAL dwUserData AS DWORD
 , BYVAL fCallback AS DWORD
 , BYREF phRatingObtainQuery AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingObtainQueryW LIB "msrating.dll" ALIAS "RatingObtainQueryW" ( BYREF pszTargetUrl AS WSTRINGZ
 , BYVAL dwUserData AS DWORD
 , BYVAL fCallback AS DWORD
 , BYREF phRatingObtainQuery AS DWORD
 ) AS LONG
DECLARE FUNCTION RatingSetupUI LIB "msrating.dll" ALIAS "RatingSetupUI" ( BYVAL hDlg AS DWORD
 , BYREF pszUsername AS ASCIIZ
 ) AS LONG
DECLARE FUNCTION RatingSetupUIW LIB "msrating.dll" ALIAS "RatingSetupUIW" ( BYVAL hDlg AS DWORD
 , BYREF pszUsername AS WSTRINGZ
 ) AS LONG
'#ifdef _INC_COMMCTRL
'STDAPI RatingAddPropertyPage(PROPSHEETHEADER *ppsh);
'#endif
'STDAPI RatingAddToApprovedSites(HWND hDlg,
' DWORD cbPasswordBlob,
' BOOL fAlwaysNever,
' BOOL fSitePage,
' BOOL fApprovedSitesEnforced);
'STDAPI RatingClickedOnPRFInternal(HWND hWndOwner, HINSTANCE /*p_hInstance*/, __in LPSTR lpszFileName, int nShow);
'STDAPI RatingClickedOnRATInternal(HWND hWndOwner, HINSTANCE /*p_hInstance*/, __in LPSTR lpszFileName, int nShow);
DECLARE FUNCTION RatingEnabledQuery LIB "msrating.dll" ALIAS "RatingEnabledQuery" ( ) AS LONG
' Not implemented
'STDAPI RatingInit();
'STDAPI_(void) RatingTerm();
'// A way to check if ratings are installed. We still need to calling
'// ratings dll to find out for sure but this allows us to delay load ratings.
'_inline BOOL IS_RATINGS_ENABLED()
'{
' TCHAR szSup[200];
' DWORD dwType;
' DWORD cbSize = sizeof(szSup);
' return (SHGetValue(HKEY_LOCAL_MACHINE,
' TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Ratings"),
' TEXT("Key"),
' &dwType, szSup, &cbSize) == ERROR_SUCCESS);
'}
FUNCTION IS_RATINGS_ENABLED_A() AS LONG
 LOCAL szSup AS ASCIIZ * 200
 LOCAL dwType AS DWORD
 LOCAL cbSize AS DWORD
 LOCAL lStatus AS LONG
 cbSize = SIZEOF(szSup)
 lStatus = SHGetValueA(%HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Policies\Ratings", "Key", dwType, szSup, cbSize)
 IF lStatus = %ERROR_SUCCESS THEN FUNCTION = %TRUE
END FUNCTION
FUNCTION IS_RATINGS_ENABLED_W() AS LONG
 LOCAL szSup AS WSTRINGZ * 200
 LOCAL dwType AS DWORD
 LOCAL cbSize AS DWORD
 LOCAL lStatus AS LONG
 cbSize = SIZEOF(szSup)
 lStatus = SHGetValueW(%HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Policies\Ratings"$$, "Key"$$, dwType, szSup, cbSize)
 IF lStatus = %ERROR_SUCCESS THEN FUNCTION = %TRUE
END FUNCTION
#IF %DEF(%UNICODE)
 MACRO IS_RATINGS_ENABLED = IS_RATINGS_ENABLED_W
#ELSE
 MACRO IS_RATINGS_ENABLED = IS_RATINGS_ENABLED_A
#ENDIF
#ENDIF
