Vb .NET - 从另一个exe更改exe中的标签 [英] Vb .NET - change label in exe from another exe

查看:89
本文介绍了Vb .NET - 从另一个exe更改exe中的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我有2个不同的项目,我需要从一个exe到另一个exe更新2个标签。我尝试用FilePut读取和放置值并生成一个新的exe,但不起作用(结果是MZ字符串)。



问候。





-Exe Sender -

Public LText1,LText2 As String



按钮 - 点击子

Dear friends,

I have 2 different projects, I need update 2 labels from one exe to another. I try to do read and put values with FilePut and generate a new exe, but dont works (Result is MZ string).

Regards.


-Exe Sender-
Public LText1, LText2 As String

Button-Click Sub

Dim s As New SaveFileDialog
s.ShowDialog()
 If s.FileName > "" Then
   LText1 = TextBox1.Text
   LText2 = TextBox2.Text
   FileOpen(1, Application.StartupPath & "\Target.exe", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
   STarget = Space(LOF(1))
   FileGet(1, STarget)
   FileClose(1)
   FileOpen(1, s.FileName & ".exe", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
   FilePut(1, STarget & LText1 & LText2)
   FileClose(1)
 End If



---------- ------------------------------------------





-Exe Target -

Public LText1,LText2 As String



表单加载子


----------------------------------------------------


-Exe Target-
Public LText1, LText2 As String

Form Load Sub

FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
LText1 = Space(LOF(1))
LText2 = Space(LOF(1))
FileGet(1, LText1)
FileGet(1, LText2)
FileClose()

Label1.Text = LText1
Label2.Text = LText2



----------------------- -----------------------------



我是什么尝试过:



尝试另一个类似的例子。

我认为另一种选择是编译一个特定的表格在项目运行时,但不知道如何做到这一点。


----------------------------------------------------

What I have tried:

Try another similar examples.
I think another option is compile a specific form in project at run time, but no have idea how to do that.

推荐答案

参见 PE内部对等:Win32可移植可执行文件格式之旅 [ ^ ]


FilePut(1, STarget & LText1 & LText2)



据我所知,这将永远不会做你想要的,代码是完全错误的。

EXE是不是平面文字,最后添加文字永远不会被考虑在内。 EXE根本不会知道你最后添加了一些文字,即使它知道,这个魔术告诉它如何处理该文本。

你需要学习如何工作,内部对于EXE,专业程序员的编辑是必须的。



你不是因为你说的而不是机械师。正确地做事需要一些练习。当一个新手拆卸电动机并重建它时,他通常最终会留下无处可去的部分。

对于程序员来说也是如此。


As far as I see this will never do what you say you want, the code is just plain wrong.
An EXE is not flat text, adding text at the end will never be taken into account. The EXE will simply not know that you added some text at the end, and even if it knew, that magic tells it what to do with that text.
You need to learn how things work, the internals of an EXE, a professional programmer's editor is a must have for this.

You are not a mechanic just because you say it. It takes some practice to do things correctly. When a newbee dismount a motor and rebuild it, he usually endup with remaining pieces that go nowhere.
Its the same for a programmer.


这篇关于Vb .NET - 从另一个exe更改exe中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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