Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 15th, 2005, 6:42 PM   #1
Mad_guy
Hobbyist Programmer
 
Mad_guy's Avatar
 
Join Date: Oct 2004
Location: Sandstorm, Techno Club
Posts: 239
Rep Power: 4 Mad_guy is on a distinguished road
Send a message via AIM to Mad_guy Send a message via MSN to Mad_guy
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.
Mad_guy is offline   Reply With Quote
Old Mar 19th, 2005, 4:51 PM   #2
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
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
kurifu is offline   Reply With Quote
Old Mar 20th, 2005, 4:01 PM   #3
layer
Hobbyist Programmer
 
Join Date: Feb 2005
Posts: 112
Rep Power: 4 layer is on a distinguished road
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
layer is offline   Reply With Quote
Old Mar 20th, 2005, 5:01 PM   #4
Mad_guy
Hobbyist Programmer
 
Mad_guy's Avatar
 
Join Date: Oct 2004
Location: Sandstorm, Techno Club
Posts: 239
Rep Power: 4 Mad_guy is on a distinguished road
Send a message via AIM to Mad_guy Send a message via MSN to Mad_guy
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.
Mad_guy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:58 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC