Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to import ddl in simple c code?

Posted on 2008-06-13
12
Medium Priority
?
295 Views
Last Modified: 2010-04-15
hello
i have created a dll using c code not C ++ ?
now i want to write another code in c which would import that dll ?
can you please help me out?
0
Comment
Question by:xPert_Umer
[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
  • 8
  • 4
12 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 21782827
You'll need to include the DLL header file, and link to the DLL lib file.

You can load a DLL explicitly too using LoadLibrary if you want.
0
 
LVL 4

Author Comment

by:xPert_Umer
ID: 21782843
is loadlibrary is c function or c++?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21782860
It is a Windows API function which can be used in both C and C++.

       http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx
0
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.

 
LVL 53

Expert Comment

by:Infinity08
ID: 21782869
And here's some example code that goes with that :

        http://msdn.microsoft.com/en-us/library/ms686944(VS.85).aspx
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21782873
And the example DLL that goes with it :

        http://msdn.microsoft.com/en-us/library/ms682507(VS.85).aspx
0
 
LVL 4

Author Comment

by:xPert_Umer
ID: 21783003
but why all code including windows.h :( ??? if it is simple c code?
 
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 1500 total points
ID: 21783047
>> but why all code including windows.h

Because it's using Windows specific stuff. Remember, a DLL is a Windows construct, it's not part of C.

windows.h defines several things that you need, like LoadLibrary, GetProcAddress, etc. If your code is not using anything from windows.h, then you don't need to include it :)
0
 
LVL 4

Author Comment

by:xPert_Umer
ID: 21783061
can you please give me a smple code? the code you sent me they dont have example of loadlibrary?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21783075
>> the code you sent me they dont have example of loadlibrary?

Yes, it does, right here :

        http://msdn.microsoft.com/en-us/library/ms686944(VS.85).aspx

Note the first two lines of the code :

        // A simple program that uses LoadLibrary and
        // GetProcAddress to access myPuts from Myputs.dll.


May I ask why you gave a B grade ? That usually means that something was missing in the answer and/or that something is still unclear. If that's the case, you don't have to close the question yet, and can ask for clarification wherever needed. Us experts prefer getting the opportunity to earn an A grade ;)
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21783084
Btw, as I said earlier, there is a simpler alternative, namely simply including the DLL header file, and linking to the DLL lib file. That's it ... nothing more - no LoadLibrary is needed in that case.
0
 
LVL 4

Author Comment

by:xPert_Umer
ID: 21784617
sorry infinity08.. i didnt get idea of A,B,C :( properly.. hope u wudnt mind:) next tym ll give A ++;)
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21784642
The grade represents the quality of the answer. The help items relevant to grades are :

        "What's the right grade to give?" : http://www.experts-exchange.com/help.jsp#hi97
        "How can I change a grade ?" : http://www.experts-exchange.com/help.jsp#hi340
        "Grade quickly and fairly" : http://www.experts-exchange.com/help.jsp#hi367

Just fyi ;)

It is meant as a feedback to the experts.



>> sorry infinity08..

No problem :) As long as your question has been answered to your satisfaction, I'm happy :)
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

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…
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…
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 while-loops in the C programming language.

670 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