Last active
October 8, 2017 17:41
-
-
Save yoh2/81369b43b6f47b5c11fb2f1ff69dfabd to your computer and use it in GitHub Desktop.
吉里吉里でのムービー再生問題 (32論理コア搭載機で再生できない) 回避プログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Text; | |
namespace KirikiriCoresAdjustor | |
{ | |
static class Program | |
{ | |
/// <summary> | |
/// アプリケーションのメイン エントリ ポイントです。 | |
/// </summary> | |
[STAThread] | |
static void Main() | |
{ | |
string[] args = Environment.GetCommandLineArgs(); | |
if (args.Length >= 2) | |
{ | |
LaunthProcess(args); | |
} | |
} | |
private static void LaunthProcess(string[] args) | |
{ | |
ProcessStartInfo startInfo = new ProcessStartInfo(args[1]); | |
startInfo.Arguments = ToArguments(args, 2); | |
using (Process process = new Process()) | |
{ | |
process.StartInfo = startInfo; | |
process.Start(); | |
if (Environment.ProcessorCount >= 32) | |
{ | |
process.WaitForInputIdle(); | |
process.ProcessorAffinity = new IntPtr(0x7fffffff); | |
} | |
} | |
} | |
private static string ToArguments(string[] args, int start) | |
{ | |
StringBuilder sb = new StringBuilder(); | |
for (int i = start; i < args.Length; i++) | |
{ | |
sb.Append('"').Append(args[i].Replace(@"\", @"\\").Replace("\"", "\\\"")).Append("\" "); | |
} | |
return sb.ToString().TrimEnd(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment