Jump to content
Forum²

Recommended Posts

Posted

Hi experts,

 

I have a strangle problem with LastInputTime from WinStationInformationW function. The problem is that it sometimes return LastInputTime with 7 min difference from its actual time. For example: last input time was at 11.10 but it returns 11.03. It usually occurs when the person logs in for the first time at the terminal server. But it can also appear during active session.

 

I don't think that the problem is in the code, because it apperars ocassionally.

 

Thank you in advance.

 

Here is the code:

 

private enum WINSTATIONINFOCLASS{

WinStationInformation = 8

}

//Works only on Windows 2000/2003

[DllImport("winsta.dll")]

private static extern int WinStationQueryInformationW(

IntPtr hServer,

uint SessionId,

uint WinStationInformation,

[Out] IntPtr Buf,

uint BufLen,

ref uint RetLen);

 

[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]

private static extern IntPtr WTSOpenServer(string ServerName);

 

[DllImport("wtsapi32.dll")]

private static extern void WTSCloseServer(IntPtr hServer);

 

public struct WinstaInfo

{

public int SessionId;

public DateTime ConnectTime;

public DateTime DisconnectTime;

public DateTime LastInputTime;

public DateTime LoginTime;

public DateTime CurrentTime;

}

 

private static DateTime FileTimeToDateTime(System.Runtime.InteropServices.ComTypes.FILETIME ft)

 

{

long hFT = (((long)ft.dwHighDateTime)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...