Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/Proxy/Windows Proxy Detection
Function:
Required plugins for this example: MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Proxy/Windows Proxy Detection
This example is the version from Sat, 7th Feb 2014.
Project "Windows Proxy Detection.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control list Inherits Listbox
ControlInstance list Inherits Listbox
End Control
EventHandler Sub Open() // if you need to test, you can use http://monkeybreadsoftware.de/proxy.pac dim URL as string = "http://www.monkeybreadsoftware.de/" dim ProxyToUse as string = "" list.AddRow "URL: "+url list.AddRow "" dim ie as WinHTTPClientCurrentUserIEProxyConfigMBS = WinHTTPClientMBS.GetIEProxyConfigForCurrentUser if ie = nil then list.AddRow "GetIEProxyConfigForCurrentUser failed." else list.AddRow "GetIEProxyConfigForCurrentUser ok" list.AddRow "AutoConfigUrl: "+ie.AutoConfigUrl list.AddRow "AutoDetect: "+str(ie.AutoDetect) list.AddRow "Proxy: "+ie.Proxy list.AddRow "ProxyBypass: "+ie.ProxyBypass ProxyToUse = ie.Proxy end if list.AddRow "" dim ii as WinHTTPClientProxyInfoMBS = WinHTTPClientMBS.GetDefaultProxyConfiguration if ii = nil then list.AddRow "GetDefaultProxyConfiguration failed." else list.AddRow "GetDefaultProxyConfiguration ok" list.AddRow "AccessType: "+str(ii.AccessType) list.AddRow "Proxy: "+ii.Proxy list.AddRow "ProxyBypass: "+ii.ProxyBypass end if list.AddRow "" dim uc as WinHTTPClientURLComponentsMBS = WinHTTPClientMBS.CrackUrl(URL) if uc = nil then list.AddRow "CrackUrl failed." else list.AddRow "CrackUrl ok" list.AddRow "HostName: "+uc.HostName list.AddRow "Port: "+str(uc.Port) list.AddRow "UserName: "+uc.UserName list.AddRow "Password: "+uc.Password list.AddRow "ExtraInfo: "+uc.ExtraInfo list.AddRow "UrlPath: "+uc.UrlPath end if list.AddRow "" dim a as new WinHTTPClientAutoProxyOptionsMBS dim AutoProxy as Boolean = false if ie<>Nil then if ie.AutoConfigUrl<>"" then AutoProxy = true end if a.Flags = a.kAutoProxyConfigURL a.AutoConfigUrl = ie.AutoConfigUrl else AutoProxy = true end if list.AddRow "AutoProxy: "+str(AutoProxy) if AutoProxy then list.AddRow "Detect..." dim h as new WinHTTPClientMBS if h.open("test", h.kAccessTypeDefaultProxy) then a.Flags = BitwiseOr(a.Flags, a.kAutoProxyAutoDetect) a.AutoDetectFlags = BitwiseOr(a.kAutoDetectTypeDHCP, a.kAutoDetectTypeDNSA) a.AutoLogonIfChallenged = true dim info as WinHTTPClientProxyInfoMBS dim b as Boolean = h.GetProxyForUrl(url, a, info) if b then list.AddRow "GetProxyForUrl ok." list.AddRow "AccessType: "+str(info.AccessType) list.AddRow "Proxy: "+info.Proxy list.AddRow "ProxyBypass: "+info.ProxyBypass ProxyToUse = info.Proxy else list.AddRow "GetProxyForUrl failed." end if else list.AddRow "Open failed." end if end if list.AddRow "" list.AddRow "ProxyToUse: "+ProxyToUse End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Win Plugin.




Links
MBS Xojo PDF Plugins