C# 从32位程序启动64位程序

时间:2021-05-13 19:57:25   收藏:0   阅读:27
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace consolex86
{
    class Program
    {
        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);

        static void Main(string[] args)
        {
            var windir = Environment.GetEnvironmentVariable("windir");
            string sysdir = "System32";
            if (!Environment.Is64BitProcess)
                sysdir = "SysNative";

            var path =  System.IO.Path.Combine(windir, sysdir,"notepad.exe");
            Process.Start(path);

            return;
        }
    }
}

 

原文:https://www.cnblogs.com/nanfei/p/14763970.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!