-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathie.cpp
147 lines (135 loc) · 4.06 KB
/
ie.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include "ie.h"
#include "qsettings.h"
#include "qdebug.h"
#include "qstring.h"
#include "qt_windows.h"
#include "qbitarray.h"
ie::ie()
{
/*
* 初始化参数
* 调用搜索函数
*/
this->name1="HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Internet Explorer\\TypedURLs";
this->name2="HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Internet Explorer\\TypedURLsTime";
this->number=0;
this->search();
}
void ie::search()
{
/*
* 读取注册表保存的IE浏览记录
*/
QStringList keys;
QSettings reg(this->name1,QSettings::NativeFormat);
keys = reg.allKeys();
for (int i=0;i<keys.length();i++)
{
this->number++;
this->name[number] = reg.value(keys[i]).toString();
}
/*
* 读取注册表保存的IE浏览时间,Windows7不支持。
*/
QStringList keys2;
QSettings reg2(this->name2,QSettings::NativeFormat);
keys2 = reg2.allKeys();
int count = 0;
int base;
/*
*读取注册表保存的16个16进制数字
* 对每个16进制数字进行处理
* 8个16进制数字转化成10进制数字再保存到FILETIME的高字节
* 8个16进制数字转化成10进制数字再保存到FILETIME的低字节
* FILETIME转换成SYSTEMTIME得到具体的时间
*/
QString c;
QString s;
QString s1,s2;
DWORD num1,num2;
for (int i=0;i<keys2.length();i++)
{
count++;
s1 = "";
s2 = "";
num1 = 0;
num2 = 0;
base = 16*16*16*16*16*16*16;
c = reg2.value(keys2[i]).toString();
const ushort *p=c.utf16();
QByteArray bytes = QByteArray::fromRawData((char*)p,c.length()*2);
s=QString::fromLocal8Bit(bytes.toHex());
for (int j=3;j>=0;j--)
{
s1 = s1 + s[j*2];
s1 = s1 + s[j*2+1];
}
for (int j=7;j>=4;j--)
{
s2 = s2 + s[j*2];
s2 = s2 + s[j*2+1];
}
for (int j=0;j<=7;j++)
{
if (s1[j].unicode()<60)
num1 = num1 + (s1[j].unicode()-48) * base;
else
num1 = num1 + (s1[j].unicode()-87) * base;
if (s2[j].unicode()<60)
num2 = num2 + (s2[j].unicode()-48) * base;
else
num2 = num2 + (s2[j].unicode()-87) * base;
base = base /16;
}
FILETIME *time = new FILETIME();
time->dwLowDateTime = num1;
time->dwHighDateTime = num2;
SYSTEMTIME st;
FileTimeToSystemTime(time,&st);
int flag=0;
if (st.wHour>=16)
flag=1;
st.wHour = (st.wHour+8) % 24;
this->time[count]+=QString::number(st.wYear)+"年";
this->time[count]+=QString::number(st.wMonth)+"月";
if (flag==0)
this->time[count]+=QString::number(st.wDay)+"日 ";
else
this->time[count]+=QString::number(st.wDay+1)+"日 ";
if (QString::number(st.wHour).length()==1)
this->time[count]+="0"+QString::number(st.wHour)+":";
else
this->time[count]+=QString::number(st.wHour)+":";
if (QString::number(st.wMinute).length()==1)
this->time[count]+="0"+QString::number(st.wMinute)+":";
else
this->time[count]+=QString::number(st.wMinute)+":";
if (QString::number(st.wSecond).length()==1)
this->time[count]+="0"+QString::number(st.wSecond);
else
this->time[count]+=QString::number(st.wSecond);
}
if (count==0)
{
for (int j=1;j<=this->number;j++)
{
this->time[j]="Windows7不记录访问时间";
}
}
//根据时间进行冒泡排序
QString temp;
for (int i=1;i<=this->number;i++)
for (int j=1;j<=i;j++)
if (this->time[i]>this->time[j])
{
temp = this->name[i];
this->name[i] = this->name[j];
this->name[j] = temp;
temp = this->time[i];
this->time[i] = this->time[j];
this->time[j] = temp;
}
}
ie::~ie()
{
}