Solved

Calling a DLL from a C prog

Posted on 1997-12-11
6
223 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

839 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