Solved

Calling a DLL from a C prog

Posted on 1997-12-11
6
225 Views
Last Modified: 2012-05-04
Hi,
How to make a call to a Dll in a C program and then create an exe.
Regards,
AC
0
Comment
Question by:achimala
[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
6 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1256631
Could you clarify what exactly you want to do. Do you want to call function in a DLL from exe written in c?
0
 

Author Comment

by:achimala
ID: 1256632
Alex,
Thank you so much for responding. I have the following things: (I)An exe, which calls the functions in anohter DLL: The code is:
#include <stdio.h>  
#include <stdlib.h>
#include <string.h>
#include <rctpub.h>
#include <memory.h>
#include <malloc.h>
#include <windows.h>
#include <profpub.h>
#include <gtipub.h>
#include <actmpub.h>
#include <rctmsg.h>
#include <elogpub.h>
#include <rctxpub.h>
#include <fetixpub.h>

int main ( int argc, char * argv[] )
{
   long lCoreSession   = 0;
   long lSessionFolder = 0;  
   int  iRV            = 0;

iRV = RctXInitializeCORESession(&lCoreSession,
&lSessionFolder,"ApplName","FendId"," " );
return(0);
}/*Works fine: doing what it is supposed to do*/

(II)A dll: the code for which is:
#include <windows.h>
int _export FAR CDECL RctXInitializeCORESession(lCoreSession, lSessionFolder,ApplName, FendId, FendPwd);

(III)What I am trying to do is: Create another exe (of course written in C), wherein I would like to call the DLL that I have created in step II!
(IV)The reason for doing all this is to use these exe's in my Oracle*Forms applications.
Regards,
AC
 
0
 
LVL 2

Expert Comment

by:AlFa
ID: 1256633
What 's your compiler version ?
0
Independent Software Vendors: 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!

 

Author Comment

by:achimala
ID: 1256634
I am using Microsoft Visual C++ version 1.52 (16-bit).
0
 
LVL 4

Accepted Solution

by:
emmons earned 100 total points
ID: 1256635
If you have written the DLL, then you should also have the LIB file associated with it, right? (if not, then run implib, like:
implib yourlib.lib yourlib.dll)
Then, all that you have to do is to include the LIB file on the link line. Something like:
link yourexe, yourexe.exe, null, libw slibcew yourlib, yourexe.def;

There is a way to do the linking dynamically, by loading the library, and then getting the address of the function that you want to call, but the implicit loading described above would seem like the way to go for you.
0
 

Author Comment

by:achimala
ID: 1256636
OK. I am trying to think back to 1.52.
You will need to change the project parameters.
Or, look in the help search for LINK, and let it tell you how to change the linking paramters.
In the dialog for linking, you will find an edit field for "Additional Libraries" that is where you add the yourlib.lib library entry.
0

Featured Post

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!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

691 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