[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VC++ Console Application & DLL File

Posted on 1998-09-29
7
Medium Priority
?
372 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

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.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

656 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