跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

提交记录
修改Core/Librarys/Win32API.cs+9 −2看文件
@@ -10,6 +10,8 @@ namespace Core.Librarys
1010{
1111 public static class Win32API
1212 {
13新增: [DllImport("user32.dll")]
14新增: public static extern IntPtr GetForegroundWindow();
1315 public delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType,
1416 IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime);
1517 [DllImport("user32.dll")]
@@ -25,6 +27,8 @@ namespace Core.Librarys
2527
2628 [DllImport("psapi.dll", SetLastError = true)]
2729 public static extern int GetModuleFileNameExA(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, int nSize);
30新增: //[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
31新增: //static extern bool QueryFullProcessImageName(IntPtr hProcess, uint dwFlags, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpExeName, ref uint lpdwSize);
2832
2933 [DllImport("kernel32.dll", SetLastError = true)]
3034 public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
@@ -49,7 +53,7 @@ namespace Core.Librarys
4953
5054
5155
52删除: [DllImport("kernel32.dll", SetLastError = true)]
56新增: [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
5357 public static extern bool QueryFullProcessImageName([In] IntPtr hProcess, [In] int dwFlags, [Out] StringBuilder lpExeName, ref int lpdwSize);
5458
5559
@@ -74,7 +78,10 @@ namespace Core.Librarys
7478 EnumChildWindows(hWnd, lpEnumFunc, pWindowinfo);
7579
7680 windowinfo = (WINDOWINFO)Marshal.PtrToStructure(pWindowinfo, typeof(WINDOWINFO));
77删除:
81新增: if (windowinfo.childpid == windowinfo.ownerpid)
82新增: {
83新增: return null;
84新增: }
7885 IntPtr proc;
7986 if ((proc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, (int)windowinfo.childpid)) == IntPtr.Zero) return null;
8087