G
Guest
What's wrong with this code?
[DllImport ("coredll.dll", SetLastError=false)]
public static extern int GetIdleTime();
[DllImport ("coredll.dll", SetLastError=false)]
public static extern int GetTickCount();
try
{
int dwStartTick = GetTickCount();
int dwIdleSt = GetIdleTime();
Application.DoEvents();
int dwStopTick = GetTickCount();
int dwIdleEd = GetIdleTime();
int PercentIdle = ((100*(dwIdleEd - dwIdleSt)) / (dwStopTick -
dwStartTick));
MessageBox.Show(PercentIdle.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
the main body of the code in a timer which fires every 20 seconds.
The messagebox shows "0" the first time it runs then i get a divde by zero
error after that.
any ideas?
I need to give focus back to my application if the pda is idle for longer
than 30 seconds.
Thanks guys.
[DllImport ("coredll.dll", SetLastError=false)]
public static extern int GetIdleTime();
[DllImport ("coredll.dll", SetLastError=false)]
public static extern int GetTickCount();
try
{
int dwStartTick = GetTickCount();
int dwIdleSt = GetIdleTime();
Application.DoEvents();
int dwStopTick = GetTickCount();
int dwIdleEd = GetIdleTime();
int PercentIdle = ((100*(dwIdleEd - dwIdleSt)) / (dwStopTick -
dwStartTick));
MessageBox.Show(PercentIdle.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
the main body of the code in a timer which fires every 20 seconds.
The messagebox shows "0" the first time it runs then i get a divde by zero
error after that.
any ideas?
I need to give focus back to my application if the pda is idle for longer
than 30 seconds.
Thanks guys.