从内存在C#中运行本地(非托管)的exe [英] run native(unmanaged) exe from memory in C#

查看:1613
本文介绍了从内存在C#中运行本地(非托管)的exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有一些使用那些在我的C#程序C程序。 我不想派与C EXE客户。这意味着我不想用户可以看到这些exe文件。 我想加载这些字节的内存并从内存中运行它。

hello i have some c program that use from those in my c# program. i dont want send those c exe to client. that mean i dont want user can see those exe. i want to load those byte to memory and run its from memory.

我怎么能做到这一点。

非常感谢。

推荐答案

如果该程序非托管code,其中一个C程序是,你不能直接从.NET中的内存启动它。你能做的就是收拾它作为一种资源,它传输到磁盘(临时文件夹),然后用的System.Diagnostics.Process类启动它。但它会显示在进程列表中。

If the program is unmanaged code, which a C program is, you cannot launch it directly from within .Net memory. What you can do is pack it as a resource, stream it to disk (a temp folder) and then start it with the System.Diagnostics.Process class. But it would show up in the process list.

但我同意从@tdammers的评论,为什么你就不能包括它旁边的计划吗?你为什么要隐藏呢?

But I agree with the comment from @tdammers, why can't you just include it alongside your program? Why do you have to hide it?

如果它已被管理,你可以弄个嵌入的资源(EXE文件),把它变成一个字节数组,并用的Assembly.Load加载它。

If it had been managed, you could get hold of the embedded resource (exe file), get it into a byte array and load it with Assembly.Load.

如果你的C程序是一个dll,你可以嵌入作为一种资源,流盘和使用的P / Invoke来执行它。

If your C program was a dll, you could embed as a resource, stream to disk and use p/invoke to execute it.

这篇关于从内存在C#中运行本地(非托管)的exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆