Link to home
Start Free TrialLog in
Avatar of wildzero
wildzero

asked on

Modify Tlabel.caption of another delphi program

Hi there,

I have two delphi programs

A.exe
B.exe

Delphi program A opens program B and modifys the resource for Tlabel.caption
then when I run program B it's Tlabel.caption is changed to what I set it in program A.

I understand this can be done with modifying the resource...

any ideas?
 
Avatar of wildzero
wildzero

ASKER

don't want any external files

program A must modify program B
and program A shouldn't have to be running at the same time as when program B is.
the best way to do it is using windows messages
here you can find a very good example how to send data between applications
http://delphi.about.com/od/windowsshellapi/a/wm_copydata.htm
and program A shouldn't have to be running at the same time as when program B is.

Any other ideas?
hm... that is pretty close to reverse engineering.

why do you want to do that modification in the first place? maybe there are other solutions. are you trying to make some branded software? if so, this can be done at compile time. modifying directly the binary is not that hard but requires some certain knowledge one might not have.
onw way to go is using a patch program:
- compile B, save output
- modify from source the caption
- compile B, save output
- run patch, see where it finds the differences. try to make out which one is the caption.

now you will have several pretty big issues here:
1) if the original caption is smaller that the one you want to assign, you will need to shift the contents of teh executable which is a pretty bad thing to do since you need to make sure you don't mess up code
2) if the original caption is smaller, issues are not that big, just in case you have a problem with displaying white spaces in teh caption.

so better tell us why you want to do that and we might think of a better approach to your problem
Hmmm now that could be an idea.

First could leave the caption blank then run
then fill the caption to it's max 255 chars then run

that way we can insert anything and just fill with blanks up to 255.

I got a program I have written which I want people to be able to insert there hyperlink into, so I guess it would be branding. Then they can distribute my program. But don't want to have to worry about any other files - just want to deal with the exe file, no tag along ini/dat files.


- run patch, see where it finds the differences. try to make out which one is the caption.

Where do I get this from :)
ASKER CERTIFIED SOLUTION
Avatar of 2266180
2266180
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for that, it's an excellent post.

Just  2 things
 1 - If I gave someone program A to make there own 'version' of progrma B (perhaps with a different video of there own for exmaple) then they would need delphi to compile the program?

 2 - Have you ever had any problems saving data to the end of a file? I done this a few times and once ran into an invalid .exe application error on one perticular XP Pro machine. They had the file fully downloaded and everything, it just didn't like it....  (worked fine on a bunch of other machines)

I will check out your link now.
Thanks
Page don't seem to wanna load :-/
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yea I bet that is what it was
some antivirus/antispyware program thought it was bad.

Hmm ok.
Now I don't quite understand your example.

Are you able to whip up a quick demo?
Program A with an edit box and Button -> Program B with a label
whatever is written in program A then shows up when Program B runs (as it pulls it from it's self).

I don't mind opening another question.

Much appreaciated
Nick
I am at work right now and can't seem to find enough "spare" time to do this. I'll put up an example for you in about 3-4 hours when I get home.
I made a qucik demo for you. I didn't spent time to integrate teh automatic build process as I already gave you a working demo for that :)
download project files from http://www.ciuly.com/delphi/ModifyExeString.zip
compile B. then write the size manuallt in size.pas then compile B again.
after you make it work manually, you can adapt the build process to your needs. maybe test it first with this deme ;)

cheers
Great
i'll check this out in a tick! thanks!
Nice that worked quite well.
And you have used this for years with no problems?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The best way to handle that is to include version B as a resource of A, then you just extract B from A and add the text to B.
That way the user will only use the latest B.

:D
Good stuff.
hm.. the user must alway use the latest A AND B. there can be a an A that works with multiple versions of B (I had that quite a few times) so the idea is not that ok. that is why I said that A must work with compatible B's. that can mean a range of versions. in my case, what I have done is to keep track of 2 versions:
1 - the program version
2- the resource version ;)
now whenever some mechanism in the resource changes, A and B gets a new version and A will only work with the version it knows no matter what B's version is (of course the B's resource version will have to be the same with the one from A's resource version)

it can be confusing to use 2 versioning but it helped me keep everything clean.
>please post in there so I can accept you to please.

sorry but EE does not accept "points for..." questions :) these are the rules, we must comply.

You can delete that question yourself to save the page editor from doing it (unless someone posts in it)

anyway, thanks for the thought :)
peace
Yea that is why I thought.
If you make it the latest B gets put into a resource file and included with A
Then A is ran the B resouce gets extracted to Progject1 and then A does the dirty work
So the only way a user can put in an old B is if he copies and old Project1 to the folder before the software has time to include the text in the one it extracted - which would be near impossible......
I thought they did...
ive done it before...

hmm