473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Externally Linking

Hello All

I am writing an application and a dll file and I was wondering how I would
access functions within the exe file from the dll?

Example:
/* EXE File */

long GetUserCount(void)
{
long count;
....
....
return count;
}

And I want to access the GetUserCount() function from in the dll.
Will I have to copy the exeapp.h to the folder with the dll project in and
link to it that way?
Or is their an easier way to do it?

I know that Half-Life connect to external functions with the mods that are
written for it but I just cant understand how to do it :(

Thanks in advance
Paul Kirby
Jul 22 '05 #1
7 1448
Paul Kirby wrote:
Hello All

I am writing an application and a dll file and I was wondering how I would
access functions within the exe file from the dll?

Example:
/* EXE File */

long GetUserCount(void)
{
long count;
...
...
return count;
}

And I want to access the GetUserCount() function from in the dll.
Will I have to copy the exeapp.h to the folder with the dll project in and
link to it that way?
Or is their an easier way to do it?

I know that Half-Life connect to external functions with the mods that are
written for it but I just cant understand how to do it :(


Standard C++ (the only thing that is topical here) has no functions for
dealing with DLL's. To do what you want you will need platform specific
functions which are off-topic here.

See also:
http://www.slack.net/~shiva/welcome.txt
http://home.wanadoo.nl/efx/c++-faq/

<offtopic>
Since you are probably using MS-Windows, you might want to look on MSDN
for the following topics: "LoadLibrary", "GetProcAddress" and "import
libraries"
</offtopic>

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #2

"Paul Kirby" <ad***@initcorp.co.uk> wrote in message
news:cb*******************@news.demon.co.uk...
Hello All

I am writing an application and a dll file and I was wondering how I would
access functions within the exe file from the dll?

The need to do this indicates poor program design.
Example:
/* EXE File */

long GetUserCount(void)
{
long count;
...
...
return count;
}

And I want to access the GetUserCount() function from in the dll.
Will I have to copy the exeapp.h to the folder with the dll project in and
link to it that way?
That does not work (as you'd find out if you tried it).
Or is their an easier way to do it?


An easier way, was the last way difficult?

First you have to clarify exactly what you want. Do you want to access the
self same code that is in the exe file, or would you be happy with an
identical copy of that code in you dll?

If its the later then it simply a matter of finding the code that contains
GetUserCount and adding that file and all its dependent files (this may not
be trivial) to your dll 'project'.

If it is the former (i.e. you want the dll to call the code that physically
exists in the exe file) then that is a difficult thing to do and you should
ask on a Windows programming groups where they will be able to tell you how
to do it on the Windows operating system, try
news:comp.os.ms-windows.programmer.win32 for instance. It may not be
possible at all (I'm not a Windows expert).

john
Jul 22 '05 #3
Paul Kirby posted:
Hello All

I am writing an application and a dll file and I was wondering how I
would access functions within the exe file from the dll?

Example:
/* EXE File */

long GetUserCount(void)
{
long count;
...
...
return count;
}

And I want to access the GetUserCount() function from in the dll.
Will I have to copy the exeapp.h to the folder with the dll project in
and link to it that way?
Or is their an easier way to do it?

I know that Half-Life connect to external functions with the mods that
are written for it but I just cant understand how to do it :(

Thanks in advance
Paul Kirby

First create the DLL. You'll also have to make a library file, .lib, out of
it. Then you'll have to make the header file. In the header file you'll have
to put:

extern "C" long GetUserCount(void);

Include the header file in the source file of you EXE prog. Set the linker
for the EXE to include .lib file for the DLL.

But ofcourse this is all OFF-TOPIC here.

Or, instead of using a .lib file, you could go the "LoadLibrary"
"GetProcAddress" route.

-JKop
Jul 22 '05 #4
"Paul Kirby" <ad***@initcorp.co.uk> wrote in
news:cb*******************@news.demon.co.uk:
Hello All

I am writing an application and a dll file and I was wondering how I
would access functions within the exe file from the dll?


You're in the wrong group. Standard C++ has no concept of a DLL. You
should wander over to the Microsoft groups and ask over there (look on the
news.microsoft.com news server).
Jul 22 '05 #5
JKop posted:
extern "C" long GetUserCount(void);


Correction,

long GetUserCount(void);
I'm just so used to seeing it in Windows header files, even though its
unneccesary!

-JKop
Jul 22 '05 #6

"Paul Kirby" <ad***@initcorp.co.uk> wrote in message
news:cb*******************@news.demon.co.uk...

EXE's in general do not provide any way to link to them externally. They're
not source code, and they're not libraries, they're stand-alone, binary
executables. Also, there is very seldom a single header file that describes
a program of any significance. You need the source code itself, so you can
compile with it, or else some documentation that tells you that you *can* do
this and how to do it on your system. The only common way that I've seen
for a DLL to call back to an EXE is for the DLL to have a function that the
EXE calls, and a parameter of that function is a pointer to a "callback"
function in the EXE. If the EXE is not written to call your DLL's function
that expects a callback function pointer, then you have no way to make use
of that feature. (Are you writing the EXE, or does it already exist as a
stand-alone app?)

-Howard
Jul 22 '05 #7
Hello All

Thanks for all the replies :)

Sorry for being off topic for this group.
Paul Kirby

"Paul Kirby" <ad***@initcorp.co.uk> wrote in message
news:cb*******************@news.demon.co.uk...
Hello All

I am writing an application and a dll file and I was wondering how I would
access functions within the exe file from the dll?

Example:
/* EXE File */

long GetUserCount(void)
{
long count;
...
...
return count;
}

And I want to access the GetUserCount() function from in the dll.
Will I have to copy the exeapp.h to the folder with the dll project in and
link to it that way?
Or is their an easier way to do it?

I know that Half-Life connect to external functions with the mods that are
written for it but I just cant understand how to do it :(

Thanks in advance
Paul Kirby

Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John A. Janes | last post by:
Here's an odd one, I'm currently developing a site for internal usage, to get around their public website, I set the internal server to port 8080 (I publish my .net from my office externally). ...
20
by: Steven T. Hatton | last post by:
I just read this in the description of how C++ is supposed to be implemented: "All external object and function references are resolved. Library components are linked to satisfy external...
1
by: John E | last post by:
I have an Access 2000 database in which there are remotely linked SQL tables and a couple of local tables. If I have queries in Access that are designed to pass data between these remote linked...
0
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database...
6
by: Rudy Ray Moore | last post by:
I work with a multi-project workspace. One project (the "startup" project) has a "Configuration Type" of "Application (.exe)". The other 40 projects have a "Configuration Type" of "Static Library...
3
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. In VB.NET, is it possible to determine whether an ASP.NET is being accessed internally (within the same domain hosting the application) or externally (across the internet)? I've looked at...
3
by: Shawn T | last post by:
I have an application with a page that has a web user control When I call that page that has this user control, locally (http:// localhost/ApplicationX/default.aspx) and also externally ie...
3
by: Spam Catcher | last post by:
Is there a way to externally add items to ASP.NET's data cache? Any sort of APIs in .NET? I have a Windows forms program which may need to add some items. Or I guess I could just call a...
1
by: donovant | last post by:
HI There, We have an in-house vb.net/C# application which basically serves as a database front end. The application was initially desgned primarily for in-house use only, however recently the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.