) 그래서 명령 인수를 사용하여 응용 프로그램을 실행하기위한 URL 프로토콜을 만들었습니다.URL 프로토콜에 대한 경로 설정 (C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Microsoft.Win32;
using System.Diagnostics;
namespace iw4Protocol
{
class Program
{
static void Main(string[] args)
{
RegistryKey key = Registry.ClassesRoot.OpenSubKey("gameProtocol");
if (key == null)
{
string iw4FullPath = Directory.GetCurrentDirectory();
gameProtocol protocol = new gameProtocol();
protocol.RegisterProtocol(gameFullPath);
}
else
{
RegistryKey gamepathkey = Registry.ClassesRoot.OpenSubKey("gameProtocol");
string gamepath = gamepathkey.GetValue("gamepath").ToString();
Environment.SetEnvironmentVariable("path",gamepath);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"test.exe";
startInfo.Arguments = Environment.CommandLine;
Process.Start(startInfo);
}
}
}
}
문제는 프로그램이 시작하려면 일부 파일이 필요하지만 경로가 '설정'되어 있지 않기 때문에 그들을로드 할 수 있다는 것입니다 :
여기 내 코드입니다.
이러한 경로를 설정하여 (예 : /cd
명령과 같은) 필요한 파일을 모두 시작할 수 있습니까?
가 Environment.SetEnvironmentVariable입니다 경로 ", 게임 경로); 오류를 던지고있는 행을? 그렇다면 PATH가 아닌가? –
http://msdn.microsoft.com/en-us/library/cb20e19t.aspx – Donal
@DanielCasserly는 그것을 시도하고 변경했습니다. – Swiftiq