请大家帮我把这几句VB代码转换成VB2010代码,谢谢了!
http://qiannao.com/file/958796636sgw/d3d68616/这是下载地址,功能是删除IEcookie的,代码不多,但调用的api太多,转得...
http://qiannao.com/file/958796636sgw/d3d68616/
这是下载地址,功能是删除IE cookie的,代码不多,但调用的api太多,转得头都大了,还是没成功,谢谢大家了
结果发我QQ邮箱好了2375381781@qq.com 展开
这是下载地址,功能是删除IE cookie的,代码不多,但调用的api太多,转得头都大了,还是没成功,谢谢大家了
结果发我QQ邮箱好了2375381781@qq.com 展开
1个回答
展开全部
附件为工程文件
Imports System.Runtime.InteropServices
Public Class Form1
Private Const NO_ERROR As Integer = 0
Private Const INTERNET_OPTION_END_BROWSER_SESSION As Integer = 42
Private Const CSIDL_COOKIES As Integer = &H21
Private Structure SHITEMID
Public cb As Int32
Public abID As Byte
End Structure
Private Structure ITEMIDLIST
Public mkid As SHITEMID
End Structure
<DllImportAttribute("shell32.dll")> _
Private Shared Function SHGetSpecialFolderLocation( _
ByVal hwndOwner As IntPtr, _
ByVal nFolder As Int32, _
ByRef ppidl As ITEMIDLIST) As Boolean
End Function
<DllImportAttribute("shell32.dll")> _
Private Shared Function SHGetPathFromIDList( _
ByVal pidl As Int32, _
ByVal pszPath As System.Text.StringBuilder) As Boolean
End Function
<DllImportAttribute("wininet.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function InternetSetOption( _
ByVal hInternet As IntPtr, _
ByVal dwOption As Int32, _
ByVal lpBuffer As IntPtr, _
ByVal dwBufferLength As Int32) As Boolean
End Function
Private Function GetSpecialfolder(ByVal CSIDL As Integer) As String
Dim r As Integer
Dim IDL As ITEMIDLIST
Dim path As New System.Text.StringBuilder(512)
'Get the special folder
r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If r = NO_ERROR Then
'Get the path from the IDList
r = SHGetPathFromIDList(IDL.mkid.cb, path)
End If
Return path.ToString()
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' 获取COOKIES文件夹路径
Dim CookiesPath As String = GetSpecialfolder(CSIDL_COOKIES)
MsgBox(CookiesPath & "A")
' 为了防止在ie打开时,内存中还有部分COOKIES存在,加了下面这句
Call InternetSetOption(0, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0)
'全部删除,如果需要删除某一个COOKIES的话,需要用dir或fso枚举出所有文件,然后用kill语句删除
Kill(CookiesPath + "\*.txt")
End Sub
End Class
追问
MsgBox(CookiesPath & "A")
这句有什么用呢?如果只是为了显示cookie路径,那为什么还要加个A呢?如果cookies路径少了一个A,那最后删除的时候路径并未发生改变啊?
追答
倒,对不起,把那行删除。那个是测试用的,忘了删掉了。
我是为了测试下路径是否以 Chr(0) 结束的。
那一行,只会弹出一个对话框显示一下路径,最后多个"A",不影响后面的删除操作。
不让我编辑最前面的回答了 = = 晕。
我把修改过的附件重新发一次。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询