开发者

Can I retrieve the user32.dll getlastinputtime from a system service

开发者 https://www.devze.com 2023-03-11 20:27 出处:网络
I am trying to write a system service that can detect whether th开发者_StackOverflowe user is active and then launch a process if not.I am using a service because I want this to work if the user is lo

I am trying to write a system service that can detect whether th开发者_StackOverflowe user is active and then launch a process if not. I am using a service because I want this to work if the user is logged in or not. I have been trying to hook into the user32.dll API and retrieve the time since last user input. However the integer being returned is always 0 so I don't think it is working correctly. Is this not possible when running as a system service?


You may like to use getlastinputinfo on user32.dll

<DllImport("user32.dll")> _
Shared Function GetLastInputInfo(ByRef plii As LASTINPUTINFO) As Boolean
End Function

<StructLayout(LayoutKind.Sequential)> _
    Structure LASTINPUTINFO
    <MarshalAs(UnmanagedType.U4)> _
    Public cbSize As Integer
    <MarshalAs(UnmanagedType.U4)> _
    Public dwTime As Integer
End Structure

LASTINPUTINFO on MSDN

0

精彩评论

暂无评论...
验证码 换一张
取 消