1

以下は、process.start の状況で問題なく機能します。

private string Path()
        {
            RegistryKey Key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wizet\\");
            RegistryKey Location = Key.OpenSubKey("MapleStory");
            return Location.GetValue("ExecPath").ToString();
        }

public bool Launch()
        {
            maplestory = new ProcessStartInfo();
            maplestory.FileName = Path() + @"\MapleStory.exe";
            maplestory.Arguments = "WebStart";

            MapleStory = Process.Start(maplestory);
}

CreateProcess を使用する場合、'.Arguments' をどこに配置し、CREATE_SUSPENDED もどこに配置しますか?

CreateProcess(AppName, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi);
4

3 に答える 3

1
public struct PROCESS_INFORMATION
{
    public IntPtr hProcess;
    public IntPtr hThread;
    public uint dwProcessId;
    public uint dwThreadId;
}

public struct STARTUPINFO
{
    public uint cb;
    public string lpReserved;
    public string lpDesktop;
    public string lpTitle;
    public uint dwX;
    public uint dwY;
    public uint dwXSize;
    public uint dwYSize;
    public uint dwXCountChars;
    public uint dwYCountChars;
    public uint dwFillAttribute;
    public uint dwFlags;
    public short wShowWindow;
    public short cbReserved2;
    public IntPtr lpReserved2;
    public IntPtr hStdInput;
    public IntPtr hStdOutput;
    public IntPtr hStdError;
}

public struct SECURITY_ATTRIBUTES
{
    public int length;
    public IntPtr lpSecurityDescriptor;
    public bool bInheritHandle;
}

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace CreateProcess
{
    public static void Main()
    {
        PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
        STARTUPINFO si = new STARTUPINFO();

        CreateProcess("MapleStory.exe", "WebStart", IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi);
    }

    [DllImport("Kernel32.dll")]
    private static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo,out PROCESS_INFORMATION lpProcessInformation);
}
于 2013-01-13T22:22:45.407 に答える
1

2番目の引数には、コマンドラインオプションを指定できます。そして6番目には、CREATE_SUSPENDEDのような作成オプションを配置できます。

CreateProcess(AppName, "WebStart", IntPtr.Zero, IntPtr.Zero, false, CREATE_SUSPENDED, IntPtr.Zero, null, ref si, out pi);

詳細については、 http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425( v = vs.85 ).aspxを参照してください。

于 2013-01-13T22:25:02.613 に答える
0
CreateProcess(AppName, "WebStart", IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi);
于 2013-01-13T22:20:27.587 に答える