c#如何获取上网历史记录
请问用c#如何获取上网历史记录?
------解决方案--------------------。。。有个System.IO.Directory,有相应的方法,你自己看看
------解决方案--------------------TextBox.AutoComplete里面有个可以自动列出上网记录的!
------解决方案--------------------[StructLayout(LayoutKind.Sequential)]
public class INTERNET_CACHE_ENTRY_INFOW
{
public uint dwStructSize;
public string lpszSourceUrlName;
public string lpszLocalFileName;
public uint CacheEntryType;
public uint dwUseCount;
public uint dwHitRate;
public uint dwSizeLow;
public uint dwSizeHigh;
public FILETIME LastModifiedTime;
public FILETIME ExpireTime;
public FILETIME LastAccessTime;
public FILETIME LastSyncTime;
public IntPtr lpHeaderInfo;
public uint dwHeaderInfoSize;
public string lpszFileExtension;
public uint dwReserved; //union uint dwExemptDelta;
}
[DllImport( "wininet.dll ")]
public static extern IntPtr FindFirstUrlCacheEntryEx(
string lpszUrlSearchPattern,
uint dwFlags,
uint dwFilter,
Int64 GroupId,
IntPtr lpFirstCacheEntryInfo,
ref uint lpdwFirstCacheEntryInfoBufferSize,
Pointer lpGroupAttributes,
Pointer pcbGroupAttributes,
Pointer lpReserved
);
[DllImport( "wininet.dll ")]
public static extern bool FindCloseUrlCache(IntPtr hEnumHandle);
[DllImport( "wininet.dll ")]
public static extern bool FindNextUrlCacheEntryEx(
IntPtr hEnumHandle,
IntPtr lpFirstCacheEntryInfo,
ref uint lpdwFirstCacheEntryInfoBufferSize,
Pointer lpGroupAttributes,
Pointer pcbGroupAttributes,
Pointer lpReserved);
public uint NORMAL_CACHE_ENTRY = 0x00000001;
private void button4_Click(object sender, EventArgs e)
{
IntPtr vHandle;
INTERNET_CACHE_ENTRY_INFOW vInternetCacheEntryInfo = new INTERNET_CACHE_ENTRY_INFOW();
uint vFirstCacheEntryInfoBufferSize = 0;
FindFirstUrlCacheEntryEx(null, 0, NORMAL_CACHE_ENTRY, 0, (IntPtr)null,
ref vFirstCacheEntryInfoBufferSize, null, null, null);
IntPtr vBuffer = Marshal.AllocHGlobal((int)vFirstCacheEntryInfoBufferSize);
vHandle = FindFirstUrlCacheEntryEx(null, 0, NORMAL_CACHE_ENTRY, 0,
vBuffer, ref vFirstCacheEntryInfoBufferSize,
null, null, null);
while (vHandle != null)
{
Marshal.PtrToStructure(vBuffer, vInternetCacheEntryInfo);
richTextBox1.AppendText(vInternetCacheEntryInfo.lpszSourceUrlName + "\r\n ");
Marshal.FreeCoTaskMem(vBuffer);
FindNextUrlCacheEntryEx(vHandle, (IntPtr)null, ref vFirstCacheEntryInfoBufferSize,
null, null, null);
vBuffer = Marshal.AllocHGlobal((int)vFirstCacheEntryInfoBufferSize);
if (!FindNextUrlCacheEntryEx(vHandle, vBuffer,
ref vFirstCacheEntryInfoBufferSize, null, null, null)) break;
}
Marshal.FreeCoTaskMem(vBuffer);
}