zoukankan      html  css  js  c++  java
  • C# 从32位程序启动64位程序

    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
Copyright © 2011-2022 走看看