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

PrivacyGetZonePreference (wininet)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("wininet.dll", SetLastError=true)]
static extern TODO PrivacyGetZonePreference(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:

None.

Tips & Tricks:

Please add some!

Sample Code (VB):

    Private Sub cmdGetPolicy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetPolicy.Click
    Dim lResult As Integer

    Dim dwZone As Integer
    Dim dwParty As Integer
    Dim dwBufferLength As Integer = 0
    Dim dwTemplate As Integer
    Dim sBuffer As StringBuilder

    dwZone = cmbZone1.SelectedIndex
    dwParty = cmbParty1.SelectedIndex

    dwBufferLength = 256
    sBuffer = New StringBuilder(" ", dwBufferLength)

    ' First we will want to make the call and get the template or the length of preference buffer
    ' 1MB in size should be enough for this test
    'sBuffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(dwBufferLength)

    lResult = WininetAPI.PrivacyGetZonePreference(dwZone, dwParty, dwTemplate, sBuffer, dwBufferLength)
    If lResult = WininetAPI.ERROR_MORE_DATA Then
        sBuffer = Nothing
        sBuffer = New StringBuilder(dwBufferLength)
        lResult = WininetAPI.PrivacyGetZonePreference(dwZone, dwParty, dwTemplate, sBuffer, dwBufferLength)
    End If

    If lResult <> 0 Then
        MsgBox("1st Party: There was an error: Code " & CStr(System.Runtime.InteropServices.Marshal.GetLastWin32Error()))
    Else
        If (dwBufferLength <= 1) Then
        txtPreference.Text = "none"
        Else
        txtPreference.Text = sBuffer.ToString
        End If

        txtTemplate.Text = CStr(dwTemplate)
    End If
    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
Edit This Page
Find References
Show Printable Version
Revisions