VB中的WebBrowser控件,自动继承了IE的绝大部分选项,它们共同按照
注册表路径HKEY_CURRENT_USER\"SOFTWARE\
MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\
User Shell Folders 下 COOKIES 项的值来设置COOKIE存储路径。我们通过改变这个值可以自定义
WebBrowser的COOKIE保存路径,但是,同时IE的COOKIE路径也被改变了。如果在改变这个值,
加载Webbrowser之后,立即恢复该项为以前的值,则不影响其他应用。大致流程如下
1、从注册表中取Cookies路径,保存
2、改变注册表中Cookie路径
3、加载Webbrowser控件或者其他基于Webbrowser的应用
4、恢复Cookie路径为以前的值
我曾向马甲管理器SwapCookie的作者PT42写信请教webbrowser设置COOKIE路径的问题,没有得到回复,
后来看到BlueFang公布的资料,才得以实现。在此对BlueFang致谢!
附上关键流程代码及演示程序cookie.zip
Dim tSet As String, tSet1 As String, tSet2 As String
tSet = REG.GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\MICROSOFT\WINDOWS\
CURRENTVERSION\EXPLORER\User Shell Folders", "Cookies")
tSet1 = REG.GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\MICROSOFT\WINDOWS\
CURRENTVERSION\EXPLORER\User Shell Folders", "Cache")
tSet2 = REG.GetRegistryValue(HKEY_CURRENT_USER,
"SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN", "Window Title")
REG.SetRegistryValue HKEY_CURRENT_USER, "SOFTWARE\MICROSOFT\WINDOWS\
CURRENTVERSION\EXPLORER\User Shell Folders", "Cookies", Text_NewPath.Text, eString
REG.SetRegistryValue HKEY_CURRENT_USER, "SOFTWARE\MICROSOFT\WINDOWS\
CURRENTVERSION\EXPLORER\User Shell Folders", "Cache", Text_NewPath.Text, eString
REG.SetRegistryValue HKEY_CURRENT_USER,
"SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN", "Window Title", Text_Title.Text, eString
internetsetoption INTERNET_OPTION_SETTINGS_CHANGED, 0, 0, 0
SendMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
Sleep (100)
Form2.Show
REG.SetRegistryValue HKEY_CURRENT_USER, "SOFTWARE\
MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\User Shell Folders", "Cookies", tSet, eString
REG.SetRegistryValue HKEY_CURRENT_USER, "SOFTWARE\
MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\User Shell Folders", "Cache", tSet1, eString
REG.SetRegistryValue HKEY_CURRENT_USER, "SOFTWARE\
MICROSOFT\INTERNET EXPLORER\MAIN", "Window Title", tSet2, eString
type="text/javascript">
正则表达式
数字处理类
包装类
遍历Map的4种方法(来自网络)
集合类
数组
字符串
语言基础
Linux下使用openssl加解密