最近笔者想作一款实时监控读取百度云管家而且在下载完成后自动推送消息到手机的小程序,一开始的思路是根据标题查找窗口句柄而后读取下载列表的句柄进而得到相关数据,然而在实践的过程当中却遇到了麻烦:如今软件为了实现漂亮的界面广泛采用了DirectUI技术,即子窗口不以窗口句柄的形式建立,因此那些控件都是没有句柄的,这就无从下手了,因而在他的目录找来找去,找到些了门道: sql
能够看到有一个叫作users的文件夹, 数据库
这里发现了一些有趣的东西,有两个相似哈希值名称的文件夹,应该就是对应我曾经登陆过的两个用户,随便点开一个看看: 小程序
从名字中不难看出一些端倪,那么问题来了,数据库该怎么读取呢? app
首先来看下数据库的类型: oop
哈哈,竟然是SQLite 数据库,这下子好办多了,咱们来看看数据库的结构: spa
表名清晰明了,想要读取文件下载历史只要读取download_history_file便可,想要实时读取下载进度的话只要读取download_file这个表便可 .net
下面是一段VB代码来做为演示: 3d
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 |
Private Sub FreshBaiduList()
Dim sPath As String sPath = App.path & "\" If mSqlite.sqlite3_initialize(sPath) = SQLITE_OK Then '// Create DB If mSqlite.sqlite3_open(BaiduUserPath & "\BaiduYunGuanjia.db", f_lSqlite) = SQLITE_OK Then ' MsgBox BaiduUserPath & "\BaiduYunGuanjia.db" '// Query values If mSqlite.sqlite3_prepare_v2(f_lSqlite, "SELECT * FROM download_file", 0, f_lStatement, 0) = SQLITE_OK Then '// Print Values View1.ListItems.Clear Set itmx = Nothing Dim i As Long i = 0 Do While mSqlite.sqlite3_step(f_lStatement) = SQLITE_ROW View1.ListItems.Add , "a" & i, mSqlite.sqlite3_column_int(f_lStatement, 0) View1.ListItems("a" & i).SubItems(1) = mSqlite.sqlite3_column_text(f_lStatement, 1) View1.ListItems("a" & i).SubItems(2) = Fix(mSqlite.sqlite3_column_text(f_lStatement, 4) / 1024 / 1024 * 100) / 100 & "MB" View1.ListItems("a" & i).SubItems(3) = mSqlite.sqlite3_column_text(f_lStatement, 3) View1.ListItems("a" & i).SubItems(4) = DateAdd("s", mSqlite.sqlite3_column_text(f_lStatement, 7), "01/01/1970 08:00:00") 'View1.ListItems("a" & i).SubItems(5) = DateAdd("s", mSqlite.sqlite3_column_text(f_lStatement, 8), "01/01/1970 08:00:00") i = i + 1 'ListView1.List Debug.Print mSqlite.sqlite3_column_int(f_lStatement, 0) Debug.Print mSqlite.sqlite3_column_text(f_lStatement, 1) Debug.Print mSqlite.sqlite3_column_text(f_lStatement, 3) Debug.Print mSqlite.sqlite3_column_text(f_lStatement, 4) Debug.Print mSqlite.sqlite3_column_text(f_lStatement, 7) Debug.Print mSqlite.sqlite3_column_text(f_lStatement, 8) Loop Next j Else Debug.Print mSqlite.sqlite3_errmsg(f_lSqlite) End If Else Debug.Print mSqlite.sqlite3_errmsg(f_lSqlite) End If Else Debug.Print "Unable to Initialize Wrapper" End If '// Release Statement Call mSqlite.sqlite3_finalize(f_lStatement) '// Close DB handle Call mSqlite.sqlite3_close(f_lSqlite) '// Terminate wrapper Call mSqlite.sqlite3_shutdown End Sub |
这样就完成了,一样的,我发现360云盘和迅雷也是利用SQLite来存储,那么他们数据库的读写就不用多说了。 orm
感谢你能把文章看到最后,若文章有不妥之处请留言指教,谢谢。sqlite