PrivacySetZonePreference (wininet)
Last changed: 65.54.188.148

.
Summary
TODO - a short description

C# Signature:

[DllImport("wininet.dll", SetLastError=true)]
static extern TODO PrivacySetZonePreference(TODO);

VB Signature:

    <DllImport("wininet.dll", SetLastError:=True, CharSet:=CharSet.Auto, EntryPoint:="PrivacySetZonePreferenceW", CallingConvention:=CallingConvention.StdCall)> _
    Shared Function PrivacySetZonePreference( ByVal dwZone As Integer, ByVal dwType As Integer, ByVal dwTemplate As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszPreference As StringBuilder) As Integer
    End Function

User-Defined Types:

    Public Const ERROR_MORE_DATA As Integer = 234
    ' URL Zone
    Public Const URLZONE_PREDEFINED_MIN As Integer = 0
    Public Const URLZONE_LOCAL_MACHINE As Integer = 0
    Public Const URLZONE_INTRANET As Integer = URLZONE_LOCAL_MACHINE + 1
    Public Const URLZONE_TRUSTED As Integer = URLZONE_INTRANET + 1
    Public Const URLZONE_INTERNET As Integer = URLZONE_TRUSTED + 1
    Public Const URLZONE_UNTRUSTED As Integer = URLZONE_INTERNET + 1
    Public Const URLZONE_PREDEFINED_MAX As Integer = 999
    Public Const URLZONE_USER_MIN As Integer = 1000
    Public Const URLZONE_USER_MAX As Integer = 10000

    ' Cookie States
    Public Const COOKIE_STATE_ACCEPT As Integer = &H1
    Public Const COOKIE_STATE_PROMPT As Integer = &H2
    Public Const COOKIE_STATE_LEASH As Integer = &H3
    Public Const COOKIE_STATE_DOWNGRADE As Integer = &H4
    Public Const COOKIE_STATE_REJECT As Integer = &H5

    ' Privacy Type
    Public Const PRIVACY_TYPE_FIRST_PARTY As Integer = 0
    Public Const PRIVACY_TYPE_THIRD_PARTY As Integer = 1

    ' Privacy Templates
    Public Const PRIVACY_TEMPLATE_NO_COOKIES As Integer = 0
    Public Const PRIVACY_TEMPLATE_HIGH As Integer = 1
    Public Const PRIVACY_TEMPLATE_MEDIUM_HIGH As Integer = 2
    Public Const PRIVACY_TEMPLATE_MEDIUM As Integer = 3
    Public Const PRIVACY_TEMPLATE_MEDIUM_LOW As Integer = 4
    Public Const PRIVACY_TEMPLATE_LOW As Integer = 5
    Public Const PRIVACY_TEMPLATE_CUSTOM As Integer = 100
    Public Const PRIVACY_TEMPLATE_ADVANCED As Integer = 101
    Public Const PRIVACY_TEMPLATE_MAX As Integer = 5

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    Private Sub cmdSetPolicy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSetPolicy.Click

    Dim dwZone As Integer
    Dim dwParty As Integer
    Dim dwTemplate As Integer
    Dim lResult As Integer
    Dim sPreference As StringBuilder
    Dim sTmp As String

    dwZone = cmbZone2.SelectedIndex
    dwParty = cmbParty2.SelectedIndex
    sTmp = cmbSetTemplate.SelectedItem
    If (sTmp.Substring(2, 1) = ")") Then
        dwTemplate = sTmp.Substring(1, 1)
    Else
        dwTemplate = sTmp.Substring(1, 3)
    End If

    If (dwTemplate = WininetAPI.PRIVACY_TEMPLATE_CUSTOM) Then
        sPreference = New StringBuilder
        If (txtPreference2.TextLength <= 0) Then
        sPreference.EnsureCapacity(2)
        sPreference.Insert(0, Chr(0))
        Else
        sPreference.Append(txtPreference2.Text)
        End If
    End If

    lResult = WininetAPI.PrivacySetZonePreference(dwZone, dwParty, dwTemplate, sPreference)
    If lResult Then
        MsgBox("There was an error: Code " & CStr(System.Runtime.InteropServices.Marshal.GetLastWin32Error()))
    End If

    MsgBox("Successfully Updated")

    End Sub

Alternative Managed API:

Do you know one? Please contribute it!

Documentation