├── .gitignore
├── .travis.yml
├── README.md
├── Sources
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── NTStatus.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ └── TimerIcon.ico
├── TimerTool.csproj
└── WinApiCalls.cs
└── TimerTool.sln
/.gitignore:
--------------------------------------------------------------------------------
1 | obj/
2 | bin/
3 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: c#
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | TimerTool
2 | =========
3 |
4 | 
5 |
6 | Little tool to get and set the windows system timer values. It uses the following WinAPI methods to retrieve and set the values:
7 |
8 | ```
9 | NtQueryTimerResolution
10 | NtSetTimerResolution
11 | TimeBeginPeriod
12 | TimeEndPeriod
13 | ```
14 |
15 | It can also set 0.5 ms as timer resolution.
16 |
17 | Verison 3 minimizes to system tray and can be started with command line arguments "-t peroidVal" and "-minimized".
18 | e.g. put a .bat file into your autostart with the following code:
19 | ```
20 | C:\PathToTool\TimerTool.exe -t 0.5 -minimized
21 | ```
22 |
23 | Or if you want to run it automatically at startup and hide the cmd after execution, update the bat file from above and replace with:
24 | ```
25 | start "" "C:\PathToTool\TimerTool.exe" -t 0.5 -minimized
26 | exit
27 | ```
28 |
29 | Download the compiled program here: http://vvvv.org/contribution/windows-system-timer-tool
30 |
31 | If you find this useful, please [donate some dev bucks on PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2DNX2JBBKED8Q), thanks!
32 |
--------------------------------------------------------------------------------
/Sources/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by SharpDevelop.
3 | * User: Tebjan Halm
4 | * Date: 21.01.2014
5 | * Time: 16:55
6 | *
7 | *
8 | */
9 | namespace TimerTool
10 | {
11 | partial class MainForm
12 | {
13 | ///
14 | /// Designer variable used to keep track of non-visual components.
15 | ///
16 | private System.ComponentModel.IContainer components = null;
17 |
18 | ///
19 | /// Disposes resources used by the form.
20 | ///
21 | /// true if managed resources should be disposed; otherwise, false.
22 | protected override void Dispose(bool disposing)
23 | {
24 | if (disposing) {
25 | if (components != null) {
26 | components.Dispose();
27 | }
28 | }
29 | base.Dispose(disposing);
30 | }
31 |
32 | ///
33 | /// This method is required for Windows Forms designer support.
34 | /// Do not change the method contents inside the source code editor. The Forms designer might
35 | /// not be able to load this method if it was changed manually.
36 | ///
37 | private void InitializeComponent()
38 | {
39 | this.components = new System.ComponentModel.Container();
40 | this.timer1 = new System.Windows.Forms.Timer(this.components);
41 | this.InfoGroupBox = new System.Windows.Forms.GroupBox();
42 | this.MaxLabel = new System.Windows.Forms.Label();
43 | this.MinLabel = new System.Windows.Forms.Label();
44 | this.CurrentLabel = new System.Windows.Forms.Label();
45 | this.ModifyGroupBox = new System.Windows.Forms.GroupBox();
46 | this.UnsetTimer = new System.Windows.Forms.Button();
47 | this.SetTimerButton = new System.Windows.Forms.Button();
48 | this.label2 = new System.Windows.Forms.Label();
49 | this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
50 | this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
51 | this.InfoGroupBox.SuspendLayout();
52 | this.ModifyGroupBox.SuspendLayout();
53 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
54 | this.SuspendLayout();
55 | //
56 | // timer1
57 | //
58 | this.timer1.Enabled = true;
59 | this.timer1.Interval = 1000;
60 | this.timer1.Tick += new System.EventHandler(this.Timer1Tick);
61 | //
62 | // InfoGroupBox
63 | //
64 | this.InfoGroupBox.Controls.Add(this.MaxLabel);
65 | this.InfoGroupBox.Controls.Add(this.MinLabel);
66 | this.InfoGroupBox.Controls.Add(this.CurrentLabel);
67 | this.InfoGroupBox.Location = new System.Drawing.Point(12, 12);
68 | this.InfoGroupBox.Name = "InfoGroupBox";
69 | this.InfoGroupBox.Size = new System.Drawing.Size(176, 85);
70 | this.InfoGroupBox.TabIndex = 1;
71 | this.InfoGroupBox.TabStop = false;
72 | this.InfoGroupBox.Text = "Timer Info";
73 | //
74 | // MaxLabel
75 | //
76 | this.MaxLabel.Location = new System.Drawing.Point(6, 62);
77 | this.MaxLabel.Name = "MaxLabel";
78 | this.MaxLabel.Size = new System.Drawing.Size(100, 20);
79 | this.MaxLabel.TabIndex = 3;
80 | this.MaxLabel.Text = "Max: 0.5 ms";
81 | //
82 | // MinLabel
83 | //
84 | this.MinLabel.Location = new System.Drawing.Point(6, 45);
85 | this.MinLabel.Name = "MinLabel";
86 | this.MinLabel.Size = new System.Drawing.Size(100, 15);
87 | this.MinLabel.TabIndex = 2;
88 | this.MinLabel.Text = "Min: 15.6 ms";
89 | //
90 | // CurrentLabel
91 | //
92 | this.CurrentLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
93 | this.CurrentLabel.Location = new System.Drawing.Point(6, 23);
94 | this.CurrentLabel.Name = "CurrentLabel";
95 | this.CurrentLabel.Size = new System.Drawing.Size(134, 18);
96 | this.CurrentLabel.TabIndex = 1;
97 | this.CurrentLabel.Text = "Current: 1 ms";
98 | //
99 | // ModifyGroupBox
100 | //
101 | this.ModifyGroupBox.Controls.Add(this.UnsetTimer);
102 | this.ModifyGroupBox.Controls.Add(this.SetTimerButton);
103 | this.ModifyGroupBox.Controls.Add(this.label2);
104 | this.ModifyGroupBox.Controls.Add(this.numericUpDown2);
105 | this.ModifyGroupBox.Location = new System.Drawing.Point(12, 103);
106 | this.ModifyGroupBox.Name = "ModifyGroupBox";
107 | this.ModifyGroupBox.Size = new System.Drawing.Size(176, 89);
108 | this.ModifyGroupBox.TabIndex = 2;
109 | this.ModifyGroupBox.TabStop = false;
110 | this.ModifyGroupBox.Text = "Modify Timer";
111 | //
112 | // UnsetTimer
113 | //
114 | this.UnsetTimer.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
115 | this.UnsetTimer.Location = new System.Drawing.Point(92, 51);
116 | this.UnsetTimer.Name = "UnsetTimer";
117 | this.UnsetTimer.Size = new System.Drawing.Size(77, 30);
118 | this.UnsetTimer.TabIndex = 7;
119 | this.UnsetTimer.Text = "Unset Timer";
120 | this.UnsetTimer.UseVisualStyleBackColor = true;
121 | this.UnsetTimer.Click += new System.EventHandler(this.UnsetTimerClick);
122 | //
123 | // SetTimerButton
124 | //
125 | this.SetTimerButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
126 | this.SetTimerButton.Location = new System.Drawing.Point(6, 51);
127 | this.SetTimerButton.Name = "SetTimerButton";
128 | this.SetTimerButton.Size = new System.Drawing.Size(80, 30);
129 | this.SetTimerButton.TabIndex = 6;
130 | this.SetTimerButton.Text = "Set Timer";
131 | this.SetTimerButton.UseVisualStyleBackColor = true;
132 | this.SetTimerButton.Click += new System.EventHandler(this.SetTimerButtonClick);
133 | //
134 | // label2
135 | //
136 | this.label2.Location = new System.Drawing.Point(69, 27);
137 | this.label2.Name = "label2";
138 | this.label2.Size = new System.Drawing.Size(100, 18);
139 | this.label2.TabIndex = 5;
140 | this.label2.Text = "ms";
141 | //
142 | // numericUpDown2
143 | //
144 | this.numericUpDown2.DecimalPlaces = 1;
145 | this.numericUpDown2.Increment = new decimal(new int[] {
146 | 5,
147 | 0,
148 | 0,
149 | 65536});
150 | this.numericUpDown2.Location = new System.Drawing.Point(6, 25);
151 | this.numericUpDown2.Name = "numericUpDown2";
152 | this.numericUpDown2.Size = new System.Drawing.Size(57, 20);
153 | this.numericUpDown2.TabIndex = 4;
154 | this.numericUpDown2.UpDownAlign = System.Windows.Forms.LeftRightAlignment.Left;
155 | this.numericUpDown2.Value = new decimal(new int[] {
156 | 5,
157 | 0,
158 | 0,
159 | 65536});
160 | //
161 | // notifyIcon1
162 | //
163 | this.notifyIcon1.Text = "notifyIcon1";
164 | this.notifyIcon1.Visible = true;
165 | //
166 | // MainForm
167 | //
168 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
169 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
170 | this.ClientSize = new System.Drawing.Size(200, 205);
171 | this.Controls.Add(this.ModifyGroupBox);
172 | this.Controls.Add(this.InfoGroupBox);
173 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
174 | this.MaximizeBox = false;
175 | this.Name = "MainForm";
176 | this.Text = "TimerTool";
177 | this.Load += new System.EventHandler(this.MainFormLoad);
178 | this.InfoGroupBox.ResumeLayout(false);
179 | this.ModifyGroupBox.ResumeLayout(false);
180 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
181 | this.ResumeLayout(false);
182 |
183 | }
184 | private System.Windows.Forms.Button UnsetTimer;
185 | private System.Windows.Forms.NumericUpDown numericUpDown2;
186 | private System.Windows.Forms.Label label2;
187 | private System.Windows.Forms.Button SetTimerButton;
188 | private System.Windows.Forms.Label MinLabel;
189 | private System.Windows.Forms.Label MaxLabel;
190 | private System.Windows.Forms.GroupBox ModifyGroupBox;
191 | private System.Windows.Forms.GroupBox InfoGroupBox;
192 | private System.Windows.Forms.Timer timer1;
193 | private System.Windows.Forms.Label CurrentLabel;
194 | private System.Windows.Forms.NotifyIcon notifyIcon1;
195 | }
196 | }
197 |
--------------------------------------------------------------------------------
/Sources/MainForm.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by SharpDevelop.
3 | * User: Tebjan Halm
4 | * Date: 21.01.2014
5 | * Time: 16:55
6 | *
7 | *
8 | */
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Drawing;
12 | using System.Resources;
13 | using System.Windows.Forms;
14 | using System.Globalization;
15 |
16 | namespace TimerTool
17 | {
18 | ///
19 | /// Description of MainForm.
20 | ///
21 | public partial class MainForm : Form
22 | {
23 | public MainForm(string[] args)
24 | {
25 | //
26 | // The InitializeComponent() call is required for Windows Forms designer support.
27 | //
28 | InitializeComponent();
29 |
30 | ResourceManager resources = new ResourceManager(typeof(MainForm));
31 |
32 | this.Resize += MainForm_Resize;
33 |
34 | notifyIcon1.BalloonTipText = "TimerTool running...";
35 | notifyIcon1.BalloonTipTitle = "TimerTool";
36 | notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
37 | notifyIcon1.Text = "TimerTool";
38 | notifyIcon1.Icon = (Icon)resources.GetObject("TimerIcon");
39 | notifyIcon1.Click += NotifyIcon1_Click;
40 |
41 | //apply commandline args
42 | allowVisible = true;
43 | var i = 0;
44 | foreach(var arg in args)
45 | {
46 |
47 | if(arg == "-t")
48 | {
49 | if (args.Length > (i + 1))
50 | {
51 | double val;
52 | if (double.TryParse(args[i+1], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out val))
53 | {
54 | WinApiCalls.SetTimerResolution((uint)(val * 10000));
55 | }
56 | }
57 | }
58 |
59 | if(arg == "-minimized")
60 | {
61 | allowVisible = false;
62 | }
63 |
64 | i++;
65 | }
66 | }
67 |
68 | private bool allowVisible; // ContextMenu's Show command used
69 | private bool allowClose = true; // ContextMenu's Exit command used
70 |
71 | protected override void SetVisibleCore(bool value)
72 | {
73 | if (!allowVisible)
74 | {
75 | value = false;
76 | if (!this.IsHandleCreated) CreateHandle();
77 | }
78 | base.SetVisibleCore(value);
79 | }
80 |
81 | protected override void OnFormClosing(FormClosingEventArgs e)
82 | {
83 | if (!allowClose)
84 | {
85 | this.Hide();
86 | e.Cancel = true;
87 | }
88 | base.OnFormClosing(e);
89 | }
90 |
91 | private void NotifyIcon1_Click(object sender, EventArgs e)
92 | {
93 | allowVisible = true;
94 | this.Show();
95 | this.WindowState = FormWindowState.Normal;
96 | this.ShowInTaskbar = true;
97 | notifyIcon1.Visible = false;
98 |
99 | }
100 |
101 | private void MainForm_Resize(object sender, EventArgs e)
102 | {
103 | if (FormWindowState.Minimized == this.WindowState)
104 | {
105 | Minimize();
106 | }
107 | else if (FormWindowState.Normal == this.WindowState)
108 | {
109 | notifyIcon1.Visible = false;
110 | }
111 | }
112 |
113 | private void Minimize()
114 | {
115 | notifyIcon1.Visible = true;
116 | notifyIcon1.ShowBalloonTip(250);
117 | this.Hide();
118 | }
119 |
120 | void MainFormLoad(object sender, EventArgs e)
121 | {
122 | DisplayTimerCaps();
123 | }
124 |
125 | private void DisplayTimerCaps()
126 | {
127 | var caps = WinApiCalls.QueryTimerResolution();
128 | CurrentLabel.Text = "Current: " + (caps.PeriodCurrent/10000.0) + " ms";
129 | MinLabel.Text = "Max: " + (caps.PeriodMin/10000.0) + " ms";
130 | MaxLabel.Text = "Min: " + (caps.PeriodMax/10000.0) + " ms";
131 | }
132 |
133 | void Timer1Tick(object sender, EventArgs e)
134 | {
135 | DisplayTimerCaps();
136 | }
137 |
138 | void SetTimerButtonClick(object sender, EventArgs e)
139 | {
140 | WinApiCalls.SetTimerResolution((uint)(numericUpDown2.Value * 10000));
141 | }
142 |
143 | void UnsetTimerClick(object sender, EventArgs e)
144 | {
145 | WinApiCalls.SetTimerResolution(0, false);
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/Sources/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | 17, 17
123 |
124 |
125 | 100, 17
126 |
127 |
128 |
129 | resources\timericon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
130 |
131 |
--------------------------------------------------------------------------------
/Sources/NTStatus.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by SharpDevelop.
3 | * User: Tebjan Halm
4 | * Date: 25.01.2014
5 | * Time: 14:08
6 | *
7 | *
8 | */
9 | using System;
10 |
11 | namespace TimerTool
12 | {
13 | ///
14 | /// A NT status value.
15 | ///
16 | public enum NtStatus : uint
17 | {
18 | // Success
19 | SuccessOrWait0 = 0x00000000,
20 | Wait1 = 0x00000001,
21 | Wait2 = 0x00000002,
22 | Wait3 = 0x00000003,
23 | Wait63 = 0x0000003f,
24 | Abandoned = 0x00000080,
25 | AbandonedWait0 = 0x00000080,
26 | AbandonedWait1 = 0x00000081,
27 | AbandonedWait2 = 0x00000082,
28 | AbandonedWait3 = 0x00000083,
29 | AbandonedWait63 = 0x000000bf,
30 | UserApc = 0x000000c0,
31 | KernelApc = 0x00000100,
32 | Alerted = 0x00000101,
33 | Timeout = 0x00000102,
34 | Pending = 0x00000103,
35 | Reparse = 0x00000104,
36 | MoreEntries = 0x00000105,
37 | NotAllAssigned = 0x00000106,
38 | SomeNotMapped = 0x00000107,
39 | OpLockBreakInProgress = 0x00000108,
40 | VolumeMounted = 0x00000109,
41 | RxActCommitted = 0x0000010a,
42 | NotifyCleanup = 0x0000010b,
43 | NotifyEnumDir = 0x0000010c,
44 | NoQuotasForAccount = 0x0000010d,
45 | PrimaryTransportConnectFailed = 0x0000010e,
46 | PageFaultTransition = 0x00000110,
47 | PageFaultDemandZero = 0x00000111,
48 | PageFaultCopyOnWrite = 0x00000112,
49 | PageFaultGuardPage = 0x00000113,
50 | PageFaultPagingFile = 0x00000114,
51 | CrashDump = 0x00000116,
52 | ReparseObject = 0x00000118,
53 | NothingToTerminate = 0x00000122,
54 | ProcessNotInJob = 0x00000123,
55 | ProcessInJob = 0x00000124,
56 | ProcessCloned = 0x00000129,
57 | FileLockedWithOnlyReaders = 0x0000012a,
58 | FileLockedWithWriters = 0x0000012b,
59 |
60 | // Informational
61 | Informational = 0x40000000,
62 | ObjectNameExists = 0x40000000,
63 | ThreadWasSuspended = 0x40000001,
64 | WorkingSetLimitRange = 0x40000002,
65 | ImageNotAtBase = 0x40000003,
66 | RegistryRecovered = 0x40000009,
67 |
68 | // Warning
69 | Warning = 0x80000000,
70 | GuardPageViolation = 0x80000001,
71 | DatatypeMisalignment = 0x80000002,
72 | Breakpoint = 0x80000003,
73 | SingleStep = 0x80000004,
74 | BufferOverflow = 0x80000005,
75 | NoMoreFiles = 0x80000006,
76 | HandlesClosed = 0x8000000a,
77 | PartialCopy = 0x8000000d,
78 | DeviceBusy = 0x80000011,
79 | InvalidEaName = 0x80000013,
80 | EaListInconsistent = 0x80000014,
81 | NoMoreEntries = 0x8000001a,
82 | LongJump = 0x80000026,
83 | DllMightBeInsecure = 0x8000002b,
84 |
85 | // Error
86 | Error = 0xc0000000,
87 | Unsuccessful = 0xc0000001,
88 | NotImplemented = 0xc0000002,
89 | InvalidInfoClass = 0xc0000003,
90 | InfoLengthMismatch = 0xc0000004,
91 | AccessViolation = 0xc0000005,
92 | InPageError = 0xc0000006,
93 | PagefileQuota = 0xc0000007,
94 | InvalidHandle = 0xc0000008,
95 | BadInitialStack = 0xc0000009,
96 | BadInitialPc = 0xc000000a,
97 | InvalidCid = 0xc000000b,
98 | TimerNotCanceled = 0xc000000c,
99 | InvalidParameter = 0xc000000d,
100 | NoSuchDevice = 0xc000000e,
101 | NoSuchFile = 0xc000000f,
102 | InvalidDeviceRequest = 0xc0000010,
103 | EndOfFile = 0xc0000011,
104 | WrongVolume = 0xc0000012,
105 | NoMediaInDevice = 0xc0000013,
106 | NoMemory = 0xc0000017,
107 | NotMappedView = 0xc0000019,
108 | UnableToFreeVm = 0xc000001a,
109 | UnableToDeleteSection = 0xc000001b,
110 | IllegalInstruction = 0xc000001d,
111 | AlreadyCommitted = 0xc0000021,
112 | AccessDenied = 0xc0000022,
113 | BufferTooSmall = 0xc0000023,
114 | ObjectTypeMismatch = 0xc0000024,
115 | NonContinuableException = 0xc0000025,
116 | BadStack = 0xc0000028,
117 | NotLocked = 0xc000002a,
118 | NotCommitted = 0xc000002d,
119 | InvalidParameterMix = 0xc0000030,
120 | ObjectNameInvalid = 0xc0000033,
121 | ObjectNameNotFound = 0xc0000034,
122 | ObjectNameCollision = 0xc0000035,
123 | ObjectPathInvalid = 0xc0000039,
124 | ObjectPathNotFound = 0xc000003a,
125 | ObjectPathSyntaxBad = 0xc000003b,
126 | DataOverrun = 0xc000003c,
127 | DataLate = 0xc000003d,
128 | DataError = 0xc000003e,
129 | CrcError = 0xc000003f,
130 | SectionTooBig = 0xc0000040,
131 | PortConnectionRefused = 0xc0000041,
132 | InvalidPortHandle = 0xc0000042,
133 | SharingViolation = 0xc0000043,
134 | QuotaExceeded = 0xc0000044,
135 | InvalidPageProtection = 0xc0000045,
136 | MutantNotOwned = 0xc0000046,
137 | SemaphoreLimitExceeded = 0xc0000047,
138 | PortAlreadySet = 0xc0000048,
139 | SectionNotImage = 0xc0000049,
140 | SuspendCountExceeded = 0xc000004a,
141 | ThreadIsTerminating = 0xc000004b,
142 | BadWorkingSetLimit = 0xc000004c,
143 | IncompatibleFileMap = 0xc000004d,
144 | SectionProtection = 0xc000004e,
145 | EasNotSupported = 0xc000004f,
146 | EaTooLarge = 0xc0000050,
147 | NonExistentEaEntry = 0xc0000051,
148 | NoEasOnFile = 0xc0000052,
149 | EaCorruptError = 0xc0000053,
150 | FileLockConflict = 0xc0000054,
151 | LockNotGranted = 0xc0000055,
152 | DeletePending = 0xc0000056,
153 | CtlFileNotSupported = 0xc0000057,
154 | UnknownRevision = 0xc0000058,
155 | RevisionMismatch = 0xc0000059,
156 | InvalidOwner = 0xc000005a,
157 | InvalidPrimaryGroup = 0xc000005b,
158 | NoImpersonationToken = 0xc000005c,
159 | CantDisableMandatory = 0xc000005d,
160 | NoLogonServers = 0xc000005e,
161 | NoSuchLogonSession = 0xc000005f,
162 | NoSuchPrivilege = 0xc0000060,
163 | PrivilegeNotHeld = 0xc0000061,
164 | InvalidAccountName = 0xc0000062,
165 | UserExists = 0xc0000063,
166 | NoSuchUser = 0xc0000064,
167 | GroupExists = 0xc0000065,
168 | NoSuchGroup = 0xc0000066,
169 | MemberInGroup = 0xc0000067,
170 | MemberNotInGroup = 0xc0000068,
171 | LastAdmin = 0xc0000069,
172 | WrongPassword = 0xc000006a,
173 | IllFormedPassword = 0xc000006b,
174 | PasswordRestriction = 0xc000006c,
175 | LogonFailure = 0xc000006d,
176 | AccountRestriction = 0xc000006e,
177 | InvalidLogonHours = 0xc000006f,
178 | InvalidWorkstation = 0xc0000070,
179 | PasswordExpired = 0xc0000071,
180 | AccountDisabled = 0xc0000072,
181 | NoneMapped = 0xc0000073,
182 | TooManyLuidsRequested = 0xc0000074,
183 | LuidsExhausted = 0xc0000075,
184 | InvalidSubAuthority = 0xc0000076,
185 | InvalidAcl = 0xc0000077,
186 | InvalidSid = 0xc0000078,
187 | InvalidSecurityDescr = 0xc0000079,
188 | ProcedureNotFound = 0xc000007a,
189 | InvalidImageFormat = 0xc000007b,
190 | NoToken = 0xc000007c,
191 | BadInheritanceAcl = 0xc000007d,
192 | RangeNotLocked = 0xc000007e,
193 | DiskFull = 0xc000007f,
194 | ServerDisabled = 0xc0000080,
195 | ServerNotDisabled = 0xc0000081,
196 | TooManyGuidsRequested = 0xc0000082,
197 | GuidsExhausted = 0xc0000083,
198 | InvalidIdAuthority = 0xc0000084,
199 | AgentsExhausted = 0xc0000085,
200 | InvalidVolumeLabel = 0xc0000086,
201 | SectionNotExtended = 0xc0000087,
202 | NotMappedData = 0xc0000088,
203 | ResourceDataNotFound = 0xc0000089,
204 | ResourceTypeNotFound = 0xc000008a,
205 | ResourceNameNotFound = 0xc000008b,
206 | ArrayBoundsExceeded = 0xc000008c,
207 | FloatDenormalOperand = 0xc000008d,
208 | FloatDivideByZero = 0xc000008e,
209 | FloatInexactResult = 0xc000008f,
210 | FloatInvalidOperation = 0xc0000090,
211 | FloatOverflow = 0xc0000091,
212 | FloatStackCheck = 0xc0000092,
213 | FloatUnderflow = 0xc0000093,
214 | IntegerDivideByZero = 0xc0000094,
215 | IntegerOverflow = 0xc0000095,
216 | PrivilegedInstruction = 0xc0000096,
217 | TooManyPagingFiles = 0xc0000097,
218 | FileInvalid = 0xc0000098,
219 | InstanceNotAvailable = 0xc00000ab,
220 | PipeNotAvailable = 0xc00000ac,
221 | InvalidPipeState = 0xc00000ad,
222 | PipeBusy = 0xc00000ae,
223 | IllegalFunction = 0xc00000af,
224 | PipeDisconnected = 0xc00000b0,
225 | PipeClosing = 0xc00000b1,
226 | PipeConnected = 0xc00000b2,
227 | PipeListening = 0xc00000b3,
228 | InvalidReadMode = 0xc00000b4,
229 | IoTimeout = 0xc00000b5,
230 | FileForcedClosed = 0xc00000b6,
231 | ProfilingNotStarted = 0xc00000b7,
232 | ProfilingNotStopped = 0xc00000b8,
233 | NotSameDevice = 0xc00000d4,
234 | FileRenamed = 0xc00000d5,
235 | CantWait = 0xc00000d8,
236 | PipeEmpty = 0xc00000d9,
237 | CantTerminateSelf = 0xc00000db,
238 | InternalError = 0xc00000e5,
239 | InvalidParameter1 = 0xc00000ef,
240 | InvalidParameter2 = 0xc00000f0,
241 | InvalidParameter3 = 0xc00000f1,
242 | InvalidParameter4 = 0xc00000f2,
243 | InvalidParameter5 = 0xc00000f3,
244 | InvalidParameter6 = 0xc00000f4,
245 | InvalidParameter7 = 0xc00000f5,
246 | InvalidParameter8 = 0xc00000f6,
247 | InvalidParameter9 = 0xc00000f7,
248 | InvalidParameter10 = 0xc00000f8,
249 | InvalidParameter11 = 0xc00000f9,
250 | InvalidParameter12 = 0xc00000fa,
251 | MappedFileSizeZero = 0xc000011e,
252 | TooManyOpenedFiles = 0xc000011f,
253 | Cancelled = 0xc0000120,
254 | CannotDelete = 0xc0000121,
255 | InvalidComputerName = 0xc0000122,
256 | FileDeleted = 0xc0000123,
257 | SpecialAccount = 0xc0000124,
258 | SpecialGroup = 0xc0000125,
259 | SpecialUser = 0xc0000126,
260 | MembersPrimaryGroup = 0xc0000127,
261 | FileClosed = 0xc0000128,
262 | TooManyThreads = 0xc0000129,
263 | ThreadNotInProcess = 0xc000012a,
264 | TokenAlreadyInUse = 0xc000012b,
265 | PagefileQuotaExceeded = 0xc000012c,
266 | CommitmentLimit = 0xc000012d,
267 | InvalidImageLeFormat = 0xc000012e,
268 | InvalidImageNotMz = 0xc000012f,
269 | InvalidImageProtect = 0xc0000130,
270 | InvalidImageWin16 = 0xc0000131,
271 | LogonServer = 0xc0000132,
272 | DifferenceAtDc = 0xc0000133,
273 | SynchronizationRequired = 0xc0000134,
274 | DllNotFound = 0xc0000135,
275 | IoPrivilegeFailed = 0xc0000137,
276 | OrdinalNotFound = 0xc0000138,
277 | EntryPointNotFound = 0xc0000139,
278 | ControlCExit = 0xc000013a,
279 | PortNotSet = 0xc0000353,
280 | DebuggerInactive = 0xc0000354,
281 | CallbackBypass = 0xc0000503,
282 | PortClosed = 0xc0000700,
283 | MessageLost = 0xc0000701,
284 | InvalidMessage = 0xc0000702,
285 | RequestCanceled = 0xc0000703,
286 | RecursiveDispatch = 0xc0000704,
287 | LpcReceiveBufferExpected = 0xc0000705,
288 | LpcInvalidConnectionUsage = 0xc0000706,
289 | LpcRequestsNotAllowed = 0xc0000707,
290 | ResourceInUse = 0xc0000708,
291 | ProcessIsProtected = 0xc0000712,
292 | VolumeDirty = 0xc0000806,
293 | FileCheckedOut = 0xc0000901,
294 | CheckOutRequired = 0xc0000902,
295 | BadFileType = 0xc0000903,
296 | FileTooLarge = 0xc0000904,
297 | FormsAuthRequired = 0xc0000905,
298 | VirusInfected = 0xc0000906,
299 | VirusDeleted = 0xc0000907,
300 | TransactionalConflict = 0xc0190001,
301 | InvalidTransaction = 0xc0190002,
302 | TransactionNotActive = 0xc0190003,
303 | TmInitializationFailed = 0xc0190004,
304 | RmNotActive = 0xc0190005,
305 | RmMetadataCorrupt = 0xc0190006,
306 | TransactionNotJoined = 0xc0190007,
307 | DirectoryNotRm = 0xc0190008,
308 | CouldNotResizeLog = 0xc0190009,
309 | TransactionsUnsupportedRemote = 0xc019000a,
310 | LogResizeInvalidSize = 0xc019000b,
311 | RemoteFileVersionMismatch = 0xc019000c,
312 | CrmProtocolAlreadyExists = 0xc019000f,
313 | TransactionPropagationFailed = 0xc0190010,
314 | CrmProtocolNotFound = 0xc0190011,
315 | TransactionSuperiorExists = 0xc0190012,
316 | TransactionRequestNotValid = 0xc0190013,
317 | TransactionNotRequested = 0xc0190014,
318 | TransactionAlreadyAborted = 0xc0190015,
319 | TransactionAlreadyCommitted = 0xc0190016,
320 | TransactionInvalidMarshallBuffer = 0xc0190017,
321 | CurrentTransactionNotValid = 0xc0190018,
322 | LogGrowthFailed = 0xc0190019,
323 | ObjectNoLongerExists = 0xc0190021,
324 | StreamMiniversionNotFound = 0xc0190022,
325 | StreamMiniversionNotValid = 0xc0190023,
326 | MiniversionInaccessibleFromSpecifiedTransaction = 0xc0190024,
327 | CantOpenMiniversionWithModifyIntent = 0xc0190025,
328 | CantCreateMoreStreamMiniversions = 0xc0190026,
329 | HandleNoLongerValid = 0xc0190028,
330 | NoTxfMetadata = 0xc0190029,
331 | LogCorruptionDetected = 0xc0190030,
332 | CantRecoverWithHandleOpen = 0xc0190031,
333 | RmDisconnected = 0xc0190032,
334 | EnlistmentNotSuperior = 0xc0190033,
335 | RecoveryNotNeeded = 0xc0190034,
336 | RmAlreadyStarted = 0xc0190035,
337 | FileIdentityNotPersistent = 0xc0190036,
338 | CantBreakTransactionalDependency = 0xc0190037,
339 | CantCrossRmBoundary = 0xc0190038,
340 | TxfDirNotEmpty = 0xc0190039,
341 | IndoubtTransactionsExist = 0xc019003a,
342 | TmVolatile = 0xc019003b,
343 | RollbackTimerExpired = 0xc019003c,
344 | TxfAttributeCorrupt = 0xc019003d,
345 | EfsNotAllowedInTransaction = 0xc019003e,
346 | TransactionalOpenNotAllowed = 0xc019003f,
347 | TransactedMappingUnsupportedRemote = 0xc0190040,
348 | TxfMetadataAlreadyPresent = 0xc0190041,
349 | TransactionScopeCallbacksNotSet = 0xc0190042,
350 | TransactionRequiredPromotion = 0xc0190043,
351 | CannotExecuteFileInTransaction = 0xc0190044,
352 | TransactionsNotFrozen = 0xc0190045,
353 |
354 | MaximumNtStatus = 0xffffffff
355 | }
356 | }
357 |
--------------------------------------------------------------------------------
/Sources/Program.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by SharpDevelop.
3 | * User: Tebjan Halm
4 | * Date: 21.01.2014
5 | * Time: 16:55
6 | *
7 | *
8 | */
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | namespace TimerTool
13 | {
14 | ///
15 | /// Class with program entry point.
16 | ///
17 | internal sealed class Program
18 | {
19 | ///
20 | /// Program entry point.
21 | ///
22 | [STAThread]
23 | private static void Main(string[] args)
24 | {
25 | Application.EnableVisualStyles();
26 | Application.SetCompatibleTextRenderingDefault(false);
27 | Application.Run(new MainForm(args));
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Sources/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region Using directives
2 |
3 | using System;
4 | using System.Reflection;
5 | using System.Runtime.InteropServices;
6 |
7 | #endregion
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("TimerTool")]
13 | [assembly: AssemblyDescription("")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("Tebjan Halm")]
16 | [assembly: AssemblyProduct("TimerTool")]
17 | [assembly: AssemblyCopyright("Copyright 2015")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // This sets the default COM visibility of types in the assembly to invisible.
22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The assembly version has following format :
26 | //
27 | // Major.Minor.Build.Revision
28 | //
29 | // You can specify all the values or you can use the default the Revision and
30 | // Build Numbers by using the '*' as shown below:
31 | [assembly: AssemblyVersion("3.0.*")]
32 |
--------------------------------------------------------------------------------
/Sources/Resources/TimerIcon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tebjan/TimerTool/043c7b3bda0f141631c18f9a54038e56cebaa3f4/Sources/Resources/TimerIcon.ico
--------------------------------------------------------------------------------
/Sources/TimerTool.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}
5 | Debug
6 | AnyCPU
7 | WinExe
8 | TimerTool
9 | TimerTool
10 | v2.0
11 |
12 |
13 | Properties
14 | False
15 | False
16 | False
17 | False
18 | obj\$(Configuration)\
19 | 4
20 |
21 |
22 | AnyCPU
23 | 4194304
24 | False
25 | Auto
26 | 4096
27 |
28 |
29 | bin\Debug\
30 | True
31 | Full
32 | False
33 | True
34 | DEBUG;TRACE
35 | obj\
36 | Project
37 |
38 |
39 | bin\Release\
40 | False
41 | None
42 | True
43 | False
44 | TRACE
45 | obj\
46 |
47 |
48 | 4194304
49 | x86
50 | False
51 | Auto
52 | 4096
53 |
54 |
55 | 4194304
56 | Itanium
57 | False
58 | Auto
59 | 4096
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Form
71 |
72 |
73 | MainForm.cs
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | MainForm.cs
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Sources/WinApiCalls.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by SharpDevelop.
3 | * User: Tebjan Halm
4 | * Date: 21.01.2014
5 | * Time: 16:55
6 | *
7 | *
8 | */
9 | using System;
10 | using System.Runtime.InteropServices;
11 | using System.Security;
12 |
13 | namespace TimerTool
14 | {
15 | [StructLayout(LayoutKind.Sequential)]
16 | public struct TimerCaps
17 | {
18 | public uint PeriodMin;
19 | public uint PeriodMax;
20 | public uint PeriodCurrent;
21 | };
22 |
23 | ///
24 | /// Description of WinApiCalls.
25 | ///
26 | public static class WinApiCalls
27 | {
28 |
29 | [DllImport("ntdll.dll", SetLastError=true)]
30 | private static extern NtStatus NtQueryTimerResolution(out uint MinimumResolution, out uint MaximumResolution, out uint ActualResolution);
31 |
32 | [DllImport("ntdll.dll", SetLastError=true)]
33 | private static extern NtStatus NtSetTimerResolution(uint DesiredResolution, bool SetResolution, ref uint CurrentResolution);
34 |
35 | public static TimerCaps QueryTimerResolution()
36 | {
37 | var caps = new TimerCaps();
38 | var result = NtQueryTimerResolution(out caps.PeriodMin, out caps.PeriodMax, out caps.PeriodCurrent);
39 | return caps;
40 | }
41 |
42 | public static ulong SetTimerResolution(uint timerResolutionIn100nsUnits, bool doSet = true)
43 | {
44 | uint currentRes = 0;
45 | var result = NtSetTimerResolution(timerResolutionIn100nsUnits, doSet, ref currentRes);
46 | return currentRes;
47 | }
48 |
49 | /// TimeBeginPeriod(). See the Windows API documentation for details.
50 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1401:PInvokesShouldNotBeVisible"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressUnmanagedCodeSecurity]
51 | [DllImport("winmm.dll", EntryPoint="timeBeginPeriod", SetLastError=true)]
52 | public static extern uint TimeBeginPeriod(uint uMilliseconds);
53 |
54 | /// TimeEndPeriod(). See the Windows API documentation for details.
55 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1401:PInvokesShouldNotBeVisible"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressUnmanagedCodeSecurity]
56 | [DllImport("winmm.dll", EntryPoint="timeEndPeriod", SetLastError=true)]
57 | public static extern uint TimeEndPeriod(uint uMilliseconds);
58 |
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/TimerTool.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | # SharpDevelop 4.3
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimerTool", "Sources\TimerTool.csproj", "{BEC25544-8CA3-411C-80F2-F757AE090EF6}"
6 | EndProject
7 | Global
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 | Debug|Any CPU = Debug|Any CPU
10 | Release|Any CPU = Release|Any CPU
11 | Debug|x86 = Debug|x86
12 | Release|x86 = Release|x86
13 | Debug|x64 = Debug|x64
14 | Release|x64 = Release|x64
15 | EndGlobalSection
16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
17 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Debug|x86.Build.0 = Debug|Any CPU
22 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Debug|x86.ActiveCfg = Debug|x86
23 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Release|x86.Build.0 = Debug|Any CPU
24 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Release|x86.ActiveCfg = Release|x86
25 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Debug|x64.Build.0 = Debug|Any CPU
26 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Debug|x64.ActiveCfg = Debug|x64
27 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Release|x64.Build.0 = Debug|Any CPU
28 | {BEC25544-8CA3-411C-80F2-F757AE090EF6}.Release|x64.ActiveCfg = Release|x64
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------