Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

PrivacySetZonePreference (wininet)
 
.
Summary

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

VB 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:

Microsoft Documentation

http://msdn.microsoft.com/library/default.asp?url=/workshop/security/privacy/reference/functions/privacysetzonepreferencew.asp?frame=true

Tips & Tricks:

Please add some!

VB 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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions