![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
Coding DLLs
Yeah, well, I've been doing C for a while, and I've finally wanted to get into DLL files, unfortunately, I have no resources or have dug up any resources on how to create them.
Would anybody mind giving me an article on how to code DLL files? I'm using Dev-C++ if it makes any difference. |
|
|
|
|
|
#2 |
|
Expert Programmer
|
You are going to want to read the entire section on DLL files over at http://msdn.microsoft.com.... there are actually a lot of things you need to know about DLLs, such as thread safety (same process and multiple process threads)... as well as what operating system you will target your DLL files for, and how some operating system and older DLLs operate (there are considerable difference between the memory mapping of a DLL file for Windows 95 and Windows XP).
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Feb 2005
Posts: 112
Rep Power: 4
![]() |
man
mna i must have searched googl for days, and tons of millions of other sites... the only way i learned was seeing code, but this is C++, dont know, maybe you'll get something out of it, maybe you wont, i dont have much to offer
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
DllClass::DllClass()
{
}
DllClass::~DllClass ()
{
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
extern "C"__declspec(dllexport) int Add (int a, int b)
{
return(a + b);
}
extern "C"__declspec(dllexport) int Multiply (int a, int b)
{
return(a * b);
}
extern "C"__declspec(dllexport) int Divide (int a, int b)
{
return(a / b);
}
extern "C"__declspec(dllexport) int Subtract (int a, int b)
{
return(a - b);
}that was made with Dev-Cpp too... im just going to be honest, but ill try I have no clue what extern "C"_dclspec does but i know that (dllexport) means that your exporting a function, not importing.. int subtract: int is the return type, which will be an integer and subtract was the name of the function, (int a, int b) are the paremeters, those will be the 2 numbers that are going to be subtracted, and the rest, well, you get the drift right? :o |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
|
I figured it out.
All I really have to do is specify my DLL functions as __declspec (dllexport) type function(); and link it as a DLL file. I figured it out looking at basic skeletons of code from Dev-C++. There's still more about DLLs that I need to read about, though. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|