Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "time" in [All]

dbghelp

.

    string dumpFileName = assemblyPath + "_" + DateTime.Now.ToString("dd.MM.yyyy.HH.mm.ss") + ".dmp";

winmm

.

Declare Function midiStreamPosition Lib "winmm.dll" (ByVal hms As IntPtr, ByVal pmmt As MMTIME, ByVal cbmmt As UInteger) As Integer

.

Structure MMTIME

.

   using System.Runtime.InteropServices;

.
Summary
The timeBeginPeriod function sets the minimum timer resolution for an application or device driver. Used to manipulate the timer frequency.
.

[DllImport("winmm.dll", EntryPoint="timeBeginPeriod")]

.

Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Integer) As Integer

.

Also see TimeGetTime (MM_GetTime) and TimeEndPeriod (MM_EndPeriod)

.

  MM_BeginPeriod(1); // set timer resolution to 1ms => freq=1000Hz

.

    // tickcount has resolution of 16.5ms, mmtime has 1ms

.

      oWriter.WriteLine("{0}: TickCount={1}, MMTime={2}", nLoop, Environment.TickCount, MM_GetTime());

.
Documentation
[timeBeginPeriod] on MSDN
.
Summary
The timeEndPeriod function clears a previously set minimum timer resolution
.

[DllImport("winmm.dll", EntryPoint="timeEndPeriod")]

.

Declare Function timeEndPeriod Lib "winmm.dll" (ByVal uPeriod As Integer) As Integer

.

Also see timeBeginPeriod and timeEndPeriod

.

See timeBeginPeriod for a sample

.
Documentation
[timeEndPeriod] on MSDN
.
Summary
The timeGetDevCaps function queries the timer device to determine its resolution.
.

static extern UInt32 timeGetDevCaps( ref TimeCaps timeCaps,

.

            UInt32 sizeTimeCaps );

.

Declare Function timeGetDevCaps Lib "winmm.dll" (ByRef lpTimeCaps As TimeCaps, ByVal uSize As UInt32) As UInt32

.

http://www.pinvoke.net/default.aspx/Structures.TimeCaps

.

Returns TIMERR_NOERROR if successful or TIMERR_STRUCT if it fails to return the timer device capabilities.

.

TIMERR_NOERROR is defined as UInt32 0 value.

.
Documentation
[timeGetDevCaps] on MSDN
.

static extern UInt32 timeGetSystemTime( ref MmTime mmTime, UInt32 sizeMmTime );

.

Declare Function timeGetSystemTime Lib "winmm.dll" (TODO) As TODO

.
Documentation
[timeGetSystemTime] on MSDN
.
Summary
The timeGetTime function retrieves the system time, in milliseconds. The system time is the time elapsed since Windows was started.
.

[DllImport("winmm.dll", EntryPoint="timeGetTime")]

.

public static extern uint MM_GetTime();

.

<DllImport("winmm.dll", EntryPoint := "timeGetTime")> _

.

Public Shared Function MM_GetTime() As UInteger

.

Unlike Environment.TickCount, you can directly set the resolution of this timer with the TimeBeginPeriod function.

.

See TimeBeginPeriod (imported as MM_BeginPeriod) and TimeEndPeriod (imported as MM_EndPeriod)

.

See TimeBeginPeriod for a sample

.
Documentation
[timeGetTime] on MSDN
.

static extern UInt32 timeKillEvent( UInt32 timerEventId );

.

Declare Function timeKillEvent Lib "winmm.dll" (TODO) As TODO

.
Documentation
[timeKillEvent] on MSDN
.

static extern UInt32 timeSetEvent( UInt32 msDelay, UInt32 msResolution,

.

            TimerEventHandler handler, ref UInt32 userCtx, UInt32 eventType );

.

Declare Function timeSetEvent Lib "winmm.dll" (TODO) As TODO

.

TimerEventHandler

.

System.Threading.Timer

.

    public class MMTimer : IDisposable

.

    static extern uint timeSetEvent(uint uDelay, uint uResolution, TimerCallback lpTimeProc, UIntPtr dwUser, uint fuEvent);

.

    static extern uint timeKillEvent(uint uTimerID);

.

    static extern uint timeGetTime();

.

    static extern uint timeBeginPeriod(uint uPeriod);

.

    static extern uint timeEndPeriod(uint uPeriod);

.

    //Timer type definitions

.

        TIME_ONESHOT = 0,      //Event occurs once, after uDelay milliseconds.

.

        TIME_PERIODIC = 1,

.

        TIME_CALLBACK_FUNCTION = 0x0000,  /* callback is function */

.

        //TIME_CALLBACK_EVENT_SET = 0x0010, /* callback is event - use SetEvent */

.

        //TIME_CALLBACK_EVENT_PULSE = 0x0020  /* callback is event - use PulseEvent */

.

    delegate void TimerCallback(uint uTimerID, uint uMsg, UIntPtr dwUser, UIntPtr dw1, UIntPtr dw2);

.

    ~MMTimer()

.

    /// The current timer instance ID

.

    TimerCallback thisCB;

.

    /// The timer elapsed event

.

    public event EventHandler Timer;

.

    protected virtual void OnTimer(EventArgs e)

.

        if (Timer != null)

.

        Timer(this, e);

.

    public MMTimer()

.

    /// Stop the current timer instance (if any)

.

            timeKillEvent(id);

.

            Debug.WriteLine("MMTimer " + id.ToString() + " stopped");

.

    /// Start a timer instance

.

    /// <param name="ms">Timer interval in milliseconds</param>

.

        //Kill any existing timer

.

        //Set the timer type flags

.

        fuEvent f = fuEvent.TIME_CALLBACK_FUNCTION | (repeat ? fuEvent.TIME_PERIODIC : fuEvent.TIME_ONESHOT);

.

        id = timeSetEvent(ms, 0, thisCB, UIntPtr.Zero, (uint)f);

.

            throw new Exception("timeSetEvent error");

.

        Debug.WriteLine("MMTimer " + id.ToString() + " started");

.

    void CBFunc(uint uTimerID, uint uMsg, UIntPtr dwUser, UIntPtr dw1, UIntPtr dw2)

.

        //Callback from the MMTimer API that fires the Timer event. Note we are in a different thread here

.

        OnTimer(new EventArgs());

.
Documentation
[timeSetEvent] on MSDN
.

<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential, CharSet:=Runtime.InteropServices.CharSet.Auto)> _

.

     <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=32)> _

.

[System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Auto)]

.

     [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 32)]

.

         waveOutGetDevCaps(i, wc, System.Runtime.InteropServices.Marshal.SizeOf(wc))  

.

using System.Runtime.InteropServices;

msi

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

urlmon

.

    Console.WriteLine("Total time to copy {0:N0} bytes = {1}", new TimeSpan(sw.ElapsedTicks))

user32

.

- The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).

.

static extern bool AnimateWindow(IntPtr hwnd, int time, AnimateWindowFlags flags);

.

Imports System.Runtime.InteropServices

.

Shared Function AnimateWindow(ByVal hwnd As IntPtr, ByVal time As Integer, ByVal flags As AnimateWindowFlags) As Boolean

.

[System.Runtime.InteropServices.DllImport("user32.dll")]

.

by using the 3 clipboard API's below first it work every time and you don't have to

.

CopyCursor reference will fail at runtime, according to documentation it is a macro:

.

    SetCaretBlinkTime(300)

.

If you come across this error "System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'parameter #6': Invalid managed/unmanaged type combination (this value type must be paired with Struct).", you may want to use

.

        [System.Runtime.InteropServices.ComRegisterFunctionAttribute()]

.

        [System.Runtime.InteropServices.ComUnregisterFunctionAttribute()]

.

I sometimes get error 1407 ("Cannot find window class.") when trying to create the window (after a successful call to RegisterClass)

.

using System.Runtime.InteropServices;

.

   IntPtr hConv, IntPtr hszItem, uint wFmt, uint wType, uint dwTimeout,

.

/// <para>The DestroyWindow function destroys the specified window. The function sends WM_DESTROY and WM_NCDESTROY messages to the window to deactivate it and remove the keyboard focus from it. The function also destroys the window's menu, flushes the thread message queue, destroys timers, removes clipboard ownership, and breaks the clipboard viewer chain (if the window is at the top of the viewer chain).</para>

.

''' <para>The DestroyWindow function destroys the specified window. The function sends WM_DESTROY and WM_NCDESTROY messages to the window to deactivate it and remove the keyboard focus from it. The function also destroys the window's menu, flushes the thread message queue, destroys timers, removes clipboard ownership, and breaks the clipboard viewer chain (if the window is at the top of the viewer chain).</para>

.

    DateTime startTime = DateTime.Now;

.

    while ((DateTime.Now - startTime).TotalMilliseconds < 500) {

.

    [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

      [System.Runtime.InteropServices.In] ref RECT lprcFrom,

.

      [System.Runtime.InteropServices.In] ref RECT lprcTo);

.

    [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]

.

    [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    <DllImport("user32.dll", CallingConvention:=Runtime.InteropServices.CallingConvention.Cdecl)> _

.

    <DllImport("user32.dll", CallingConvention:=Runtime.InteropServices.CallingConvention.Cdecl)> _

.

Imports System.Runtime.InteropServices

.

using System.Runtime.InteropServices;

.

<Runtime.InteropServices.DllImport("user32.dll")>

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

Imports System.Runtime.InteropServices

.

    public UInt32 dwTimeout;

.

    FLASHW_TIMER = 4,

.

    FLASHW_TIMERNOFG = 12

.

    fInfo.dwTimeout = 0;

.

        fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;

.

        fInfo.dwTimeout = 0;

.

    FLASHW_TIMER = 4

.

    FLASHW_TIMERNOFG = 12

.

    Public dwTimeout As Long

.

        If FlashCount = 0 Then .dwFlags = .dwFlags Or FlashWindowFlags.FLASHW_TIMERNOFG

.

        .dwTimeout = 0 ' Use the default cursor blink rate.

.

        .cbSize = System.Runtime.InteropServices.Marshal.SizeOf(fwi)

.

    public UInt32 dwTimeout;

.

    FLASHW_TIMER = 4,

.

    FLASHW_TIMERNOFG = 12

.

    fInfo.dwTimeout = 0;

.

        fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;

.

        fInfo.dwTimeout = 0;

.

    FLASHW_TIMER = 4

.

    FLASHW_TIMERNOFG = 12

.

    Public dwTimeout As Long

.

        If FlashCount = 0 Then .dwFlags = .dwFlags Or FlashWindowFlags.FLASHW_TIMERNOFG

.

        .dwTimeout = 0 ' Use the default cursor blink rate.

.

        .cbSize = System.Runtime.InteropServices.Marshal.SizeOf(fwi)

.

    private void timer1_Tick(object sender, EventArgs e)

.

        timer1.Interval = 3;

.

Imports System.Runtime.InteropServices

.

     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

.
Summary
.

static extern uint GetCaretBlinkTime();

.

Is there some Windows Message posted when the user changes the Blink Time in the system control ?

.

Use SystemInformation.CaretBlinkTime property

.

[GetCaretBlinkTime] on MSDN

.

using System.Runtime.InteropServices;

.

cbi.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(cbi);

.

cbi.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(cbi)

.

<System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _

.

using System.Runtime.InteropServices;

.

<System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _

.
Summary
.

static extern uint GetDoubleClickTime();

.

Declare Function GetDoubleClickTime Lib "user32.dll" () As Integer

.

System.Windows.Forms.SystemInformation.DoubleClickTime (http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.doubleclicktime.aspx)

.
Documentation
[GetDoubleClickTime] on MSDN
.

    using System.Runtime.InteropServices;

.

   <System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint:="GetIconInfo")>  _

.

    Public Shared Function GetIconInfo(ByVal hIcon As System.IntPtr, ByRef piconinfo As ICONINFO) As <System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)> Boolean

.

    using System.Runtime.InteropServices;

.

    using System.Runtime.InteropServices;

.

    using System.Runtime.InteropServices;

.

Imports System.Runtime.InteropServices

.

    using System.Runtime.InteropServices;

.
Summary
The GetKeyState function retrieves the status of the specified virtual key. The status specifies whether the key is up, down, or toggled (on, off—alternating each time the key is pressed).
.

Use Runtime.InteropServices.Marshal.GetLastWin32Error()

.
Summary
Gets the time of the last user input (in ms since the system started)
.

     dwTime : uint32

.

Compare to Environment.TickCount to get the time since the last user input.

.

These samples do not take into account the rollover of the tick counter which will occur after ~50 days of uptime.

.

This function retrieves the time in seconds since last user input

.

    static uint GetLastInputTime()

.

        uint idleTime = 0;

.

        lastInputInfo.dwTime = 0;

.

        uint lastInputTick = lastInputInfo.dwTime;

.

        idleTime = envTicks - lastInputTick;

.

        return (( idleTime > 0 ) ? ( idleTime / 1000 ) : 0);

.

This function retrieves the time in seconds since last user input

.

Dim idletime As Integer

.

   Public Function GetLastInputTime() As Integer

.

    idletime = 0

.

    lastInputInf.dwTime = 0

.

        idletime = Environment.TickCount - lastInputInf.dwTime

.

    If idletime > 0 Then

.

        Return idletime / 1000

.

This function retrieves the time in seconds since last user input

.

public: static double getSystemIdleTime()

.

    int systemUptime = Environment::TickCount;

.

    lastInputInfo.dwTime = 0;

.

        int lastInputTicks = (int)lastInputInfo.dwTime;

.

        idleTicks = systemUptime - lastInputTicks;

.

let idleTimeSeconds() =

.

     let mutable info = { size = size; dwTime = 0u }

.

     let idleTicks = now - info.dwTime

.

Prints time in seconds since last user input.

.

    int systemUptime = GetTickCount();    // was Environment.TickCount

.

    lastInputInfo.dwTime = 0;

.

        int lastInputTicks = (int)lastInputInfo.dwTime;

.

        idleTicks = systemUptime - lastInputTicks;

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

        public int time ;             //Specifies the time stamp of the mouse coordinate

.

        QS_TIMER =      0x0010,

.

        QS_ALLEVENTS = (QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY),

.

        QS_ALLINPUT = (QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE)

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

    [System.Runtime.InteropServices.DllImport("user32.dll")]

.

     Imports System.Runtime.InteropServices

.

  Imports System.Runtime.InteropServices

.
Summary
The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area. GetWindowDC assigns default attributes to the window device context each time it retrieves the device context. Previous attributes are lost.
.

        wpTemp.Length = System.Runtime.InteropServices.Marshal.SizeOf(wpTemp)

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: