如何用VB清理上网产生的cookies
cookies里存有户用名和密码.我要用VB清理掉.最好给代码.1.2楼的方法都不行.再打开网站的时候Login还是存在.Cookie:Tracker=JEuWPvS1O...
cookies里存有户用名和密码.我要用VB清理掉.最好给代码.
1.2楼的方法都不行.再打开网站的时候Login还是存在.
Cookie: Tracker=JEuWPvS1OzYJUHawewOpPRKO2ZApVeWt;Login=ZXKBGyELGcp9EuDpUgfQCTF___dyX$wgKsP5ro25v4fNtMEj$XTMQKJsGsbhbCyX___qsKQ8WXd7tp8=
Cookie: Tracker=JEuWPvS1OzYJUHawewOpPRKO2ZApVeWt 这种才是我想要的 展开
1.2楼的方法都不行.再打开网站的时候Login还是存在.
Cookie: Tracker=JEuWPvS1OzYJUHawewOpPRKO2ZApVeWt;Login=ZXKBGyELGcp9EuDpUgfQCTF___dyX$wgKsP5ro25v4fNtMEj$XTMQKJsGsbhbCyX___qsKQ8WXd7tp8=
Cookie: Tracker=JEuWPvS1OzYJUHawewOpPRKO2ZApVeWt 这种才是我想要的 展开
2个回答
2009-03-25
展开全部
正在使用的当然不能删除了。~
Option Explicit
Private Const NO_ERROR = 0
Private Const INTERNET_OPTION_END_BROWSER_SESSION = 42
Private Const CSIDL_COOKIES = &H21&
Private Type SHITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hInternet As Long, ByVal dwOption As Long, ByRef lpBuffer As Any, ByVal dwBufferLength As Long) As Long
Private Function GetSpecialfolder(CSIDL As Long) As String
Dim r As Long
Dim IDL As ITEMIDLIST
'Get the special folder
Dim path As String
r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If r = NO_ERROR Then
'Create a buffer
path = Space$(512)
'Get the path from the IDList
r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal path$)
'Remove the unnecessary chr$(0)'s
GetSpecialfolder = Left$(path, InStr(path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End Function
Private Sub Command1_Click()
Dim CookiesPath As String
CookiesPath = GetSpecialfolder(CSIDL_COOKIES) '获取COOKIES文件夹路径
'为了防止在ie打开时,内存中还有部分COOKIES存在,加了下面这句
Call InternetSetOption(0, INTERNET_OPTION_END_BROWSER_SESSION, ByVal 0&, 0)
Kill CookiesPath + "\*.txt" '全部删除,如果需要删除某一个COOKIES的话,需要用dir或fso枚举出所有文件,然后用kill语句删除
End Sub
这样做会更安全一点~
Option Explicit
Private Const NO_ERROR = 0
Private Const INTERNET_OPTION_END_BROWSER_SESSION = 42
Private Const CSIDL_COOKIES = &H21&
Private Type SHITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hInternet As Long, ByVal dwOption As Long, ByRef lpBuffer As Any, ByVal dwBufferLength As Long) As Long
Private Function GetSpecialfolder(CSIDL As Long) As String
Dim r As Long
Dim IDL As ITEMIDLIST
'Get the special folder
Dim path As String
r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If r = NO_ERROR Then
'Create a buffer
path = Space$(512)
'Get the path from the IDList
r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal path$)
'Remove the unnecessary chr$(0)'s
GetSpecialfolder = Left$(path, InStr(path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End Function
Private Sub Command1_Click()
Dim CookiesPath As String
CookiesPath = GetSpecialfolder(CSIDL_COOKIES) '获取COOKIES文件夹路径
'为了防止在ie打开时,内存中还有部分COOKIES存在,加了下面这句
Call InternetSetOption(0, INTERNET_OPTION_END_BROWSER_SESSION, ByVal 0&, 0)
Kill CookiesPath + "\*.txt" '全部删除,如果需要删除某一个COOKIES的话,需要用dir或fso枚举出所有文件,然后用kill语句删除
End Sub
这样做会更安全一点~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询