?
Solved

VC++ Console Application & DLL File

Posted on 1998-09-29
7
Medium Priority
?
371 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Accepted Solution

by:
NullTerminator earned 210 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

764 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