Solved

VC++ Console Application & DLL File

Posted on 1998-09-29
7
361 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
  • 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

  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 …
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now