954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

DLL and Application

Hi to all,
I want to know how to get into dll file.
I do not now anythig about dll.
I do now something about Applications.
So if you can give some link with example and with dllEntryPoint i will send the GOD's to Answer your wishes(:D).I have nothing to offer.

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

A DLL is not very different than an EXE. (Both are PE32 files.) The primary difference is how they are expected to be used. (That is by no means the only significant difference, so you can't just rename your DLLs to EXEs and expect them to work...)

You might start out by checking out what MSDN has to say .

If by "get into a dll file" you mean that you want a list of its import and/or export tables, then google "pe32 import export table" to get started. There are system APIs to help here.

Hope this helps.

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

Yes it help but not enought for makeing suff.
I want i code example.
And can i calculate numbers in dll and back them to windows Application because i learn dll to do this.

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

So what you want to do is create your own DLL which your application can use to do something?

What programming environment are you using (compiler/IDE)?

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

Yes yes yes

GCC/DEV-C++

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

But i using Dev-C++ and those tutorial for VC++.

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

doesn't matter what compiler you use. If you want to write a DLL then you need to create all those files as shown in the tutorial.

To start the DLL project select menu File --> New --> Project then select the DLL icon.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

I allready try it and the
C:\Dev-Cpp\Makefile.win [Build Error] No rule to make target `"../Documents', needed by `Project1.dll'. Stop.

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

Did you create a DLL project when you got to the window that listed all the different project types? I did, then tried to compile what Dev-C++ generated and got an error that the linker can not find dllcrt0.o even though its in the lib directory. I'm trying to find the solution to this problem.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
Did you create a DLL project when you got to the window that listed all the different project types? I did, then tried to compile what Dev-C++ generated and got an error that the linker can not find dllcrt0.o even though its in the lib directory. I'm trying to find the solution to this problem.


Thank you very much for your effort.
You are like my right hand.

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

Hi,
Can anyone explain why do i need header( .h) and
( .c) for creating DLL in C?
When i usally open Dev-C++->project dll, i got 2 files 1 cdll.h and 1 cmain.c ,and whan i compile i got a project.dll .Few words woud be grathfull .
Thank you for your reading.

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

Hi ,
i discovered why did't work you and me with Dev-C++,because you and i have
Include linking wich it can't bedone in such small programs.
Project option->files->cdll.c
turn off include linking.But i findout it in the other turtorial http://www.apitalk.com/document.php?id=1184209001_1

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

Hi, i created my dll and i call it myfile.dll
And i open Win32 clean project and put these files and it doesend work why?

#include <windows.h>



typedef void (*function1_ptr) ();

function1_ptr function1=NULL;





int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { 

    

    HMODULE myDll = LoadLibrary("myfile.dll"); 

    

    if(myDll)      

       function1 = (function1_ptr) GetProcAddress(myDll,"function1");  

    

    if(function1)  

       function1();

        

    FreeLibrary(myDll);



    return 0;

}
kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

What did not work ?

LoadLibrary
GetProcAddress
function1()
or
FreeLibrary ?

If LoadLibrary did not work, look in keep dll in the same folder of exe.
if GetProcAddress did not work
try dumpbin -exports \myfile.dll in command prompt of visual studio to check if function1 is exported from the dll. Make sure you give right path of the dll.
if function1 did not work see your implimentation.
if FreeLibrary did not work, don't worry anyways yopu are ending your application.

dubeyprateek
Junior Poster
176 posts since Mar 2006
Reputation Points: 39
Solved Threads: 24
 

Hi , i use Dev-C++
That file working but not right because he must put my MessageBox on the screen Here is myfile.dll

#include <windows.h>

extern "C" {
    
    //functions callable in dll
    void __declspec (dllexport) function1() {
        MessageBox (NULL, "test message","test title",0);
    }
    
}

BOOL WINAPI DllMain (HINSTANCE, DWORD, LPVOID) {
    return TRUE;
}


Thank you for your effort of reading.

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

I don't use LoadLibrary() for most DLLs that I write. Instead, I just use __dllimport and prototype it in the *.c or *.cpp application program, then link with the *.lib file that the compiler generated when the DLL was compiled and linked. But of course if you don't have a *.lib file then this method will not work.

// prototype the function that is in the DLL
void __declspec (dlimport) function1();

int main()
{
     function1(); // call the function in the DLL

     return 0;
}
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

There is should ne bo reason why MessageBox should fail provided you make that call and system is not running out of handles.

int __declspec (dllexport) function1() {
        if(IDOK != MessageBox (NULL, "test message","test title",MB_OK))
        {
        	DWORD dw = GetLastError();
	return dw;
         }
         return 0;
    }


change your implimentation as shown above and get the error code.

dubeyprateek
Junior Poster
176 posts since Mar 2006
Reputation Points: 39
Solved Threads: 24
 

What ever ,if you have a any file wich will explain to me what to do in ( .lib) .Please post it.
And if you know how to create ( .lib) plz post it here.
Thank you for your time.

kv79
Posting Whiz in Training
292 posts since Nov 2007
Reputation Points: 30
Solved Threads: 7
 

.lib is always created once you create a dll. You can include that .lib in linker options of your project then you dont need to call LoadLibrary. it is static linking of dll.
However, your implimentation is right if all the API calls are working and function() is exported(it is exported) you should see MessageBox.
Please change the implimentation and get me the error code.

dubeyprateek
Junior Poster
176 posts since Mar 2006
Reputation Points: 39
Solved Threads: 24
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You