Solved

Calling a DLL from a C prog

Posted on 1997-12-11
6
219 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
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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

910 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

19 Experts available now in Live!

Get 1:1 Help Now