🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8980

Re: Is it possible to Read a Value from another EXE-file?

#8980
From: Bob Gonder
Date: Thu, 26 Aug 2004 15:37
20 lines
1849 bytes
PC Hua wrote:

>In my project there are 2 executable files A and B. I want to make sure 
>that the user has a copy of A when he runs B (just for license reason).
>Can I define data (for identification) in A which can be read from B?

Yes. As long as A isn't compressed (with PkLite or such).
Open the exe file (with CreateFile) with OpenExisiting and ReadOnly
attributes. And search for your data.  In the code for A, you would
have a unique string such as "ExeA==oK".  If you find the file, and it
contains your secret string, then all is fine.

>Alternatively, I will call A from B and A will return a value to identify 
>itself.
>How do I make A knows it's called by B so that A will only return a value 
>instead of running the program?

Pass a secret parameter.. "A.exe  ShowMeYourCode"
if( 0 == strcmp( argv[1], "ShowMeYourCode" ) )
	exit(MySecretCode);
Technical Details
Message-ID: <ne0si01gnlvn5600p5u5c563fhi7vundam@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <opsdbpl9bxpmxkmr@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,7027a3c3c5d1c750
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Is it possible to Read a Value from another EXE-file?
Date: Thu, 26 Aug 2004 08:37:59 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <ne0si01gnlvn5600p5u5c563fhi7vundam@4ax.com>
References: <opsdbpl9bxpmxkmr@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 65.41.123.145
X-Trace: newsgroups.borland.com 1093534678 65.41.123.145 (26 Aug 2004 08:37:58 -0700)
Lines: 22
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail