Solved

VC++ Console Application & DLL File

Posted on 1998-09-29
7
368 Views
Last Modified: 2008-03-06
I have a CGI/Console application that I want to add a DLL file(s) to.  I have found plenty of resources on how to do this in a windows environment, but not in a DOS/Console application environment.  Does anyone know how or where a good resource is that describes this process.  Or even sample code would be appreciated.  

Thanks
0
Comment
Question by:delvin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 7

Expert Comment

by:faster
ID: 1174041
As long as it is windows console program, you can use DLL just as you do it in normal windows application.  You can link with a import lib or use LoadLibrary(), all win32 API works.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1174042
DOS programs cannot use DLLs.  DOS was written 10 years prior to the first DLL.

But a win32 console program looks a lot like a DOS program to the user.  It looks a lot like a standard C++ program to the programmer.  And it has complete access to the windows API functions and 32 bit memory.  I suspect you are using a win32 console program already (not DOS), but if not, there is a good chance that you can easily change to a win32 console program with little effort.  (Note VC 5 and 6 do not produce DOS programs.  If that is what you are using, you already have a console program.)
0
 

Author Comment

by:delvin
ID: 1174043
Do you know of a good book that covers this topic?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
NullTerminator earned 70 total points
ID: 1174044
Like Nietod said, dos itself does not support dlls at all. If you are using MSVC 4 or better you can't really create a straight dos program.  But for a console app, you can use dll.

Assume you have header file for functions in the dll
include that header in your app file

///////////////////////////////////
// myDLL.h
int someFunc(int argIN);
///////////////////////////////////

When you build the dll the linker also creates a .lib file
Add the LIB file to your project to resolve linker calls at
compile time.  Open your project,  select Build | Settings -- Link Tab -- Drop down select input,  add the path to your lib.   Make Sure the dll is in the path or in the same directory where you will run the executable.

///////////////////////////////////////////////////////
//source for dll
extern "C" int someFunc(int argIn) { return argIn; }

DllMain(....) { etc. }
//////////////////////////////////////////////////////

///////////////////////////////////////////////////
// MyDLL.def file   USED BY DLL BUILD
LIBRARY                MYDLL
EXPORTS
      someFunc     @1
/////////////////////////////////////////////////

HTH
'\0'
0
 
LVL 22

Expert Comment

by:nietod
ID: 1174045
>> Do you know of a good book that covers this topic?
What topic?  DLLs?  That is not that big an issue that a book would be devoted to it.  Any introductory windows programming book will do.  The VC on-line help will as well.
0
 
LVL 7

Expert Comment

by:faster
ID: 1174046
You don't need any book if you already know tranditional windows programming.
0
 

Author Comment

by:delvin
ID: 1174047
Thanks ALL!  I should be able to take it from here. :)  I can always count on the experts at the experts-exchange to come through.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 82
Embarcadero C++ Builder XE2 TDateTime 8 90
How to convert MFC APP to Win32 APP. 19 131
FMX TCameraComponent Problem 2 105
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question