Notifying a message in Action center.
Revision | bac4db89f68c658ed2954910b4f295f8cccc7d90 (tree) |
---|---|
Time | 2015-01-31 13:46:21 |
Author | JeffyTS <JeffyTS@outl...> |
Commiter | JeffyTS |
Improved checking whether VM tools running.
@@ -125,19 +125,27 @@ namespace CtrlVix | ||
125 | 125 | CloseVixObject(IVM); |
126 | 126 | IHost.Disconnect(); |
127 | 127 | // 数回再実行する |
128 | - for (int i = 1; i <= 10; i++) | |
128 | + for (int i = 1; i <= 5; i++) | |
129 | 129 | { |
130 | 130 | #if DEBUG |
131 | 131 | Debug.WriteLine("VIX: ReRunVMControl x" + i.ToString("D")); |
132 | 132 | #endif |
133 | 133 | System.Threading.Thread.Sleep(5000); // 5sec wait |
134 | 134 | if (reRunVMOperation(vmxFilePath, powerOP)) return true; |
135 | + // if (GetVMState(vmxFilePath) != Constants.VMSTATE.ERROR) return true; | |
135 | 136 | } |
136 | - ErrMessage(VixCOM.Constants.VIX_E_POWEROP_SCRIPTS_NOT_AVAILABLE); | |
137 | + if (CheckToolsRunnnging(vmxFilePath) != Constants.TOOLS_RUNNING.RUNNING) | |
138 | + { | |
139 | + // toolが動いていないときはエラーとはしない | |
140 | + // ErrMessage(VixCOM.Constants.VIX_E_TIMEOUT_WAITING_FOR_TOOLS); | |
141 | + return true; | |
142 | + } | |
143 | + ErrMessage(VixCOM.Constants.VIX_E_TIMEOUT_WAITING_FOR_TOOLS); | |
137 | 144 | return false; |
138 | 145 | } |
139 | 146 | // SUSPED させたとき VM_NOT_RUNNNINGはエラーとはしない |
140 | - else if ((powerOP == Constants.POWEROP.SUSPEND) && (IVixLib.ErrorCode(err) == VixCOM.Constants.VIX_E_VM_NOT_RUNNING)) | |
147 | + else if ((powerOP == Constants.POWEROP.SUSPEND) && | |
148 | + (IVixLib.ErrorCode(err) == VixCOM.Constants.VIX_E_VM_NOT_RUNNING)) | |
141 | 149 | { |
142 | 150 | // NOP |
143 | 151 | } |
@@ -497,6 +505,9 @@ namespace CtrlVix | ||
497 | 505 | if ((toolsState & VixCOM.Constants.VIX_TOOLSSTATE_RUNNING) == VixCOM.Constants.VIX_TOOLSSTATE_RUNNING) |
498 | 506 | { |
499 | 507 | vmState = vmState | VixCOM.Constants.VIX_POWERSTATE_TOOLS_RUNNING; // プロパティを見てもちゃんと判定できないので手動でフラグを立てる |
508 | +//#if DEBUG | |
509 | +// Debug.WriteLine("VIX: Can't determine tools running."); | |
510 | +//#endif | |
500 | 511 | } |
501 | 512 | CloseVixObject(IVM); |
502 | 513 | IHost.Disconnect(); |
@@ -661,13 +672,22 @@ namespace CtrlVix | ||
661 | 672 | private void ErrMessage(ulong err) |
662 | 673 | { |
663 | 674 | VixCOM.IVixLib IVixLib = new VixCOM.VixLib(); |
664 | - if (err == 0x4000) | |
675 | + if (err == VixCOM.Constants.VIX_E_VM_NOT_FOUND) // 0x4000 | |
665 | 676 | { |
666 | 677 | #if DEBUG |
667 | 678 | Debug.WriteLine("VIX: VIX file not found"); |
668 | 679 | #endif |
669 | 680 | return; // vix file not found no時は無視する |
670 | 681 | } |
682 | + /*** | |
683 | + if (err == VixCOM.Constants.VIX_E_POWEROP_SCRIPTS_NOT_AVAILABLE) // 0x3009 | |
684 | + { | |
685 | +#if DEBUG | |
686 | + Debug.WriteLine("VIX: VIX_E_POWEROP_SCRIPTS_NOT_AVAILABLE"); | |
687 | +#endif | |
688 | + return; // VIX_E_POWEROP_SCRIPTS_NOT_AVAILABLE時は無視する | |
689 | + } | |
690 | + ***/ | |
671 | 691 | #if DEBUG |
672 | 692 | // 文字化けのため |
673 | 693 | string a = IVixLib.GetErrorText(err, null); |
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | ||
32 | 32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を |
33 | 33 | // 既定値にすることができます: |
34 | 34 | // [assembly: AssemblyVersion("1.0.*")] |
35 | -[assembly: AssemblyVersion("1.1.0.0")] | |
36 | -[assembly: AssemblyFileVersion("1.1.0.0")] | |
35 | +[assembly: AssemblyVersion("1.1.1.0")] | |
36 | +[assembly: AssemblyFileVersion("1.1.1.0")] |
@@ -35,6 +35,7 @@ namespace VMwPlayerTaskTray | ||
35 | 35 | private const string MSG_BALN_WARN = "GUI/NoGUI couldn't be determined when guest OS started by \"VMware Player\". " + |
36 | 36 | "It might be cause of loosing control."; |
37 | 37 | private const string MSG_BALN_NO_VMX_FILE = ".vmx\" file not found. Check your VM path."; |
38 | + private const string MSG_BALN_NOT_RUNNING_VMTOOLS = "VM tools might be not running. Check your VM."; | |
38 | 39 | |
39 | 40 | // クラス内のグローバル変数 |
40 | 41 | private enum VMSTATE : int // ChangeMenuItem() |
@@ -66,6 +67,7 @@ namespace VMwPlayerTaskTray | ||
66 | 67 | POWERED_OFF, |
67 | 68 | CANNOT_DEFINE_RUNNING_MODE, |
68 | 69 | NO_VMXFILE, |
70 | + NOT_RUNNING_VMTOOLS, | |
69 | 71 | ERROR = 0xffff |
70 | 72 | }; |
71 | 73 |
@@ -267,29 +269,38 @@ namespace VMwPlayerTaskTray | ||
267 | 269 | } |
268 | 270 | else if (vmState == VMSTATE.POWERED_ON) |
269 | 271 | { |
270 | - switch (Vix.CheckRunningMode(vmxFilePath)) | |
272 | + if (Vix.CheckToolsRunnnging(vmxFilePath) != CtrlVix.Constants.TOOLS_RUNNING.RUNNING) | |
271 | 273 | { |
272 | - case CtrlVix.Constants.RUNNING_MODE.GUI: | |
273 | - // GUI mode | |
274 | - SetMenuItem(MENU_MODE.RUNNING_GUI); | |
274 | + SetMenuItem(MENU_MODE.NOT_RUNNING_VMTOOLS); | |
275 | 275 | #if DEBUG |
276 | - Debug.WriteLine("RUNNING_GUI"); | |
276 | + Debug.WriteLine("NOT_RUNNING_VMTOOLS"); | |
277 | 277 | #endif |
278 | - break; | |
279 | - case CtrlVix.Constants.RUNNING_MODE.NOGUI: | |
280 | - // No GUI mode | |
281 | - SetMenuItem(MENU_MODE.RUNNING_NOGUI); | |
278 | + } | |
279 | + else{ | |
280 | + switch (Vix.CheckRunningMode(vmxFilePath)) | |
281 | + { | |
282 | + case CtrlVix.Constants.RUNNING_MODE.GUI: | |
283 | + // GUI mode | |
284 | + SetMenuItem(MENU_MODE.RUNNING_GUI); | |
282 | 285 | #if DEBUG |
283 | - Debug.WriteLine("RUNNING_NOGUI"); | |
286 | + Debug.WriteLine("RUNNING_GUI"); | |
284 | 287 | #endif |
285 | - break; | |
286 | - case CtrlVix.Constants.RUNNING_MODE.CANNOT_DETERMINE: | |
287 | - // Guest OS started by VMware Player - can't determine GUI/NGUI | |
288 | - SetMenuItem(MENU_MODE.CANNOT_DEFINE_RUNNING_MODE); | |
288 | + break; | |
289 | + case CtrlVix.Constants.RUNNING_MODE.NOGUI: | |
290 | + // No GUI mode | |
291 | + SetMenuItem(MENU_MODE.RUNNING_NOGUI); | |
289 | 292 | #if DEBUG |
290 | - Debug.WriteLine("CANNOT_DEFINE_RUNNING_MODE"); | |
293 | + Debug.WriteLine("RUNNING_NOGUI"); | |
291 | 294 | #endif |
292 | - break; | |
295 | + break; | |
296 | + case CtrlVix.Constants.RUNNING_MODE.CANNOT_DETERMINE: | |
297 | + // Guest OS started by VMware Player - can't determine GUI/NGUI | |
298 | + SetMenuItem(MENU_MODE.CANNOT_DEFINE_RUNNING_MODE); | |
299 | +#if DEBUG | |
300 | + Debug.WriteLine("CANNOT_DEFINE_RUNNING_MODE"); | |
301 | +#endif | |
302 | + break; | |
303 | + } | |
293 | 304 | } |
294 | 305 | } |
295 | 306 | else if (vmState == VMSTATE.NO_VMXFILE) |
@@ -397,6 +408,16 @@ namespace VMwPlayerTaskTray | ||
397 | 408 | this.notifyIcon_MainForm.Icon = Properties.Resources.VMwPlayerTaskTray_err; |
398 | 409 | this.notifyIcon_MainForm.ShowBalloonTip(500); // バルーンTip表示 |
399 | 410 | break; |
411 | + case MENU_MODE.NOT_RUNNING_VMTOOLS: | |
412 | + ToolStripMenuItem_GoGUI.Enabled = false; | |
413 | + ToolStripMenuItem_GoNoGUI.Enabled = false; | |
414 | + ToolStripMenuItem_GoSuspend.Enabled = false; | |
415 | + ToolStripMenuItem_OtherCommand.Enabled = false; | |
416 | + this.notifyIcon_MainForm.Text = "VM tools not runnning - " + vmxName; | |
417 | + this.notifyIcon_MainForm.BalloonTipText = "\"" + vmxName + MSG_BALN_NOT_RUNNING_VMTOOLS; | |
418 | + this.notifyIcon_MainForm.Icon = Properties.Resources.VMwPlayerTaskTray_err; | |
419 | + this.notifyIcon_MainForm.ShowBalloonTip(500); // バルーンTip表示 | |
420 | + break; | |
400 | 421 | case MENU_MODE.ERROR: |
401 | 422 | default: |
402 | 423 | ToolStripMenuItem_GoGUI.Enabled = false; |
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | ||
32 | 32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を |
33 | 33 | // 既定値にすることができます: |
34 | 34 | // [assembly: AssemblyVersion("1.0.*")] |
35 | -[assembly: AssemblyVersion("1.1.0.*")] | |
36 | -[assembly: AssemblyFileVersion("1.1.0.0")] | |
35 | +[assembly: AssemblyVersion("1.1.1.*")] | |
36 | +[assembly: AssemblyFileVersion("1.1.1.0")] |
@@ -40,6 +40,7 @@ Rlease & modify | ||
40 | 40 | 2015/01/10 1.0.4 Separated source files. |
41 | 41 | 2015/01/20 1.0.5 Improved error messages. |
42 | 42 | 2015/01/22 1.1.0 Change to x64 appication. |
43 | + 2015/01/31 1.1.1 Improved checking whether VM tools running. | |
43 | 44 | |
44 | 45 | |
45 | 46 |