473,785 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(vo id)
{
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 1475
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(vo id)
{
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: "LoadLibrar y", "GetProcAddress " and "import
libraries"
</offtopic>

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

"Paul Kirby" <ad***@initcorp .co.uk> wrote in message
news:cb******** ***********@new s.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(vo id)
{
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.program mer.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(vo id)
{
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(vo id);

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 "LoadLibrar y"
"GetProcAddress " route.

-JKop
Jul 22 '05 #4
"Paul Kirby" <ad***@initcorp .co.uk> wrote in
news:cb******** ***********@new s.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(vo id);


Correction,

long GetUserCount(vo id);
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******** ***********@new s.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******** ***********@new s.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(vo id)
{
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
287
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). There is no problem at all accessing the site externally, but it is almost impossible to access internally. I checked to make sure I have no references in the site to the external publishing address. This may be a very simple problem, but one I...
20
3239
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 references to functions and objects not defined in the current translation. All such translator output is collected into a program image which contains information needed for execution in its execution environment." What I'm wondering is what exactly...
1
5656
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 and local tables, is it possible to execute these queries externally (i.e. from outwith Access) using, for example, .NET/C#? Or is it possible to run an Access user defined function or macro externally which then in turn deals with the queries? ...
0
2248
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 that is used to connect to other databases and generate reports. below is sample code of how the database does the linking i hope i give you enough info to help me but if not let me know and i will give more. Sub txtShipDataFileSub() Dim...
6
6578
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 (.lib)". My question: Should the linker incrementally link when I make a change to one of the ..cpps in one of my .lib projects? For VC6 the answer is yes.
3
1397
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 using the HttpRequest.ServerVariables Property, but it doesn't look like it's NameValueCollection contains any items which would identify whether or not a program is being accessed internally/externally. Basically I need to apply certain logic...
3
3399
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 (http:// <webserver>/ApplicationX/default.aspx), the display is all different. For example, a text box shows with border on one and textbox shows as label in the other. I am suspecting that it might be CSS issue. I checked the CSS file and everything...
3
1215
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 webpage. Hmm. -- spamhoneypot@rogers.com (Do not e-mail)
1
1635
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 apllication is being by a few users working from home, and they have come accross a few issues which did not occur when they used the application in the office. The main issue is that the batch report generator function of the application generates...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.