パスでプロセスを強制終了したくありません。しかし、このコードを使用すると、win32Exception が発生します。
ReadProcessMemory または WriteProcessMemory 要求の一部のみが完了しました
ターゲット ビルドを x64 に変更しましたが、それでも同じエラーが発生します。
Process[] Processes = Process.GetProcessesByName("iw4");
if (Processes.Length >= 1)
{
for (int i = 1; i < Processes.Length; i++)
{
Process Process = Processes[i];
string processPath = Process.MainModule.FileName;
if (processPath == s + "\\iw4.exe")
{
if (!File.Exists(s + "\\localization.txt"))
{
Log.Data("killed process!");
Process.Kill();
}
}
}
}
スタックトレース:
at System.Diagnostics.NtProcexssManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
at System.Diagnostics.Process.get_MainModule()
at LocalizationFix.Fix.checkLocalizationFile()
at LocalizationFix.Init.Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()