473,395 Members | 1,348 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,395 software developers and data experts.

Create DLL with undecorated names

I want to create an "MFC DLL" with VC.NET that will be explicitly loaded
when needed. That is, the main application will do a "LoadLibrary" call and
then a series of "GetProcAddress" calls to set up the entry points. What I
want is to be able to refer to the entry points as simple names, e.g.,
"MyFunction", as opposed to the "decorated" names that C++ generates by
default. So what I am asking about is the syntax for declaring the functions
in the DLL code.

I think I've done this in the distant past, and all I remember is stringing
together a lot of declarations and macros like "__dllexport", "WINAPI",
"__stdcall", etc. Does anyone have an example of how to do what I am looking
for here? Thanks.

Doug G
Nov 17 '05 #1
4 4148
Doug Gordon wrote:

I want to create an "MFC DLL" with VC.NET that will be explicitly loaded
when needed. That is, the main application will do a "LoadLibrary" call and
then a series of "GetProcAddress" calls to set up the entry points. What I
want is to be able to refer to the entry points as simple names, e.g.,
"MyFunction", as opposed to the "decorated" names that C++ generates by
default. So what I am asking about is the syntax for declaring the functions
in the DLL code.

I think I've done this in the distant past, and all I remember is stringing
together a lot of declarations and macros like "__dllexport", "WINAPI",
"__stdcall", etc. Does anyone have an example of how to do what I am looking
for here? Thanks.

Doug G


extern "C" is the only answer that you will get from this newsgroup.
__dllexport, et al. will need to be addressed in a Windows specific newsgroup.
Nov 17 '05 #2
Julie wrote:

Doug Gordon wrote:

I want to create an "MFC DLL" with VC.NET that will be explicitly loaded
when needed. That is, the main application will do a "LoadLibrary" call and
then a series of "GetProcAddress" calls to set up the entry points. What I
want is to be able to refer to the entry points as simple names, e.g.,
"MyFunction", as opposed to the "decorated" names that C++ generates by
default. So what I am asking about is the syntax for declaring the functions
in the DLL code.

I think I've done this in the distant past, and all I remember is stringing
together a lot of declarations and macros like "__dllexport", "WINAPI",
"__stdcall", etc. Does anyone have an example of how to do what I am looking
for here? Thanks.

Doug G


extern "C" is the only answer that you will get from this newsgroup.
__dllexport, et al. will need to be addressed in a Windows specific newsgroup.


Scratch that! I thought I was in comp.lang.c++ -- sorry!

Here is what you need to do:

#ifdef __cplusplus
extern "C" {
#endif

__dllexport void YourFunctionHere(int some, int another);

#ifdef __cplusplus
}
#endif

That should do the trick for you.
Nov 17 '05 #3
(from MSDN)
There are three methods for exporting a definition, listed in recommended
order of use:

__declspec(dllexport) in the source code
An EXPORTS statement in a .def file
An /EXPORT specification in a LINK command

All three methods can be used in the same program. When LINK builds a
program that contains exports, it also creates an import library, unless an
..exp file is used in the build.

LINK uses decorated forms of identifiers. The compiler decorates an
identifier when it creates the .obj file. If entryname is specified to the
linker in its undecorated form (as it appears in the source code), LINK
attempts to match the name. If it cannot find a unique match, LINK issues an
error message. Use the DUMPBIN tool to get the decorated names form of an
identifier when you need to specify it to the linker.
.....

(or use to extern "C" to "undecorated" the name)
Each one has it's plus ans minus.

Reagrds Jan

"Doug Gordon" <go******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
I want to create an "MFC DLL" with VC.NET that will be explicitly loaded
when needed. That is, the main application will do a "LoadLibrary" call and then a series of "GetProcAddress" calls to set up the entry points. What I
want is to be able to refer to the entry points as simple names, e.g.,
"MyFunction", as opposed to the "decorated" names that C++ generates by
default. So what I am asking about is the syntax for declaring the functions in the DLL code.

I think I've done this in the distant past, and all I remember is stringing together a lot of declarations and macros like "__dllexport", "WINAPI",
"__stdcall", etc. Does anyone have an example of how to do what I am looking for here? Thanks.

Doug G

Nov 17 '05 #4
Julie wrote:

Julie wrote:

Doug Gordon wrote:

I want to create an "MFC DLL" with VC.NET that will be explicitly loaded
when needed. That is, the main application will do a "LoadLibrary" call and
then a series of "GetProcAddress" calls to set up the entry points. What I
want is to be able to refer to the entry points as simple names, e.g.,
"MyFunction", as opposed to the "decorated" names that C++ generates by
default. So what I am asking about is the syntax for declaring the functions
in the DLL code.

I think I've done this in the distant past, and all I remember is stringing
together a lot of declarations and macros like "__dllexport", "WINAPI",
"__stdcall", etc. Does anyone have an example of how to do what I am looking
for here? Thanks.

Doug G


extern "C" is the only answer that you will get from this newsgroup.
__dllexport, et al. will need to be addressed in a Windows specific newsgroup.


Scratch that! I thought I was in comp.lang.c++ -- sorry!

Here is what you need to do:

#ifdef __cplusplus
extern "C" {
#endif

__dllexport void YourFunctionHere(int some, int another);

#ifdef __cplusplus
}
#endif

That should do the trick for you.


I'm striking out on this one: replace __dllexport with __declspec(dllexport).
Nov 17 '05 #5

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

Similar topics

7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
24
by: flkeyman | last post by:
Work in legal office. Trying to create solid designed database structure. This is list of tables w/fields and primary keys. Any comments/advice greatly appreciated. tbl-Defendants CaseNumber...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
8
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 ,...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
1
by: clir | last post by:
Hi, I'm trying to create views on all my existing tables and for that I'd like to create a script or so. I don't want to specify the '*' for the columns in the create view statement. I prefer...
0
by: whatnameisnottaken | last post by:
Hi was wondering if anyone could help me with this problem. I used imagehlp to undecorate dll function names. Now i need help on how to write a parsing algorithm to place the proper class member...
0
by: ramcbe | last post by:
hello, i am very new to vc++.i have the code. #include "windows.h" #include "stdafx.h" // Need the following header files to access the MSI API #include "msi.h" #include "msiquery.h"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.