Thread: pasting code form a .txt file...

  1. #16
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    No. DLL's, from what I've read (I haven't used them yet), are deceptively easy to use. Once you've gotten that first bit of code that you pasted written, for loading the DLL, you use the functions that you've loaded just as if they were defined in your source code and not in the DLL. The DLLClass thing you're looking at is, I'm guessing, a class written by some third party in order to make DLL loading/using easier - however, if you want to know how to REALLY use dll's, I suggest you read up on them. It's fairly easy, and you seem to be a fast learner.

    I found this link earlier today (I got sort of curious). It seems to be a decent tutorial that gets you off the ground, even if it doesn't explain how things work in detail.
    http://www.flipcode.com/tutorials/tut_dll01.shtml
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #17
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    oooh man! Thanks so much for that link! I can do it finally! The example source code was perfect and the functions are pretty self explanitory (if you don't know what they are there for put them there anyways!)!!!!

    Thanks so much!!!!


    Edit: Project Chi Chi is going to be dll mania! LOL

  3. #18
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Heh, no problem... always glad to help

    Strangely, when I googled for that link just before posting, I couldn't find it... it seemed to have vanished off the face of Google (it was one of the first links in the first search I did originally)! Good thing it was in my browser history though...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #19
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    yah gotta love that history...well ok not really. But I have seen that before to. It is wierd...

  5. #20
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Cool, now I can make a Chip8 Emulator that uses Graphics Plugins

    EDIT:
    For those of you who don't know what a Chip 8 is.. It was a type of language interpreter back in 70's that ran on RCA stuff... resolution was 64x32 and had either black or white to choose from for pixel color.
    I tihnk you can see why I need a plug-in system
    Last edited by Vicious; 09-07-2004 at 04:57 PM.

  6. #21
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    gl hf.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #22
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    LOL all I'm getting is problem after probeblem now... lol


    Edit: Oh and there sorce code doesn't even compile in dev-cpp. This crap is useless to me now...

  8. #23
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Ok can anyone explain on how to put functions in this?


    .cpp file...

    Code:
    /* 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;
    }

    and the .h file is...


    Code:
    #ifndef _DLL_H_
    #define _DLL_H_
    
    #if BUILDING_DLL
    # define DLLIMPORT __declspec (dllexport)
    #else /* Not BUILDING_DLL */
    # define DLLIMPORT __declspec (dllimport)
    #endif /* Not BUILDING_DLL */
    
    
    class DLLIMPORT DllClass
    {
      public:
        DllClass();
        virtual ~DllClass(void);
    
      private:
    
    };
    
    
    #endif /* _DLL_H_ */

    thanks

  9. #24
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    As I've never used DLLs before, I'm hardly an authority on them. But it would appear that this example is used for storing a class definition in a DLL. Are you trying to do so? If not, I'd stick to just using plain global functions. They do the trick just fine, and are probably much easier and less confusing to use with DLLs.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #25
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    global functions...I used them when I made games with game maker. But I still want to use the dll idea but, rrr this is making me mad!

  11. #26
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Ok now it is asking for a host. I have swiched my way of using dlls and it apears to be working but it askes for a host file. What the heck is this? It did thsi with the class code I gave too. And when I specify a .exe host nothing happens.

  12. #27
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>global functions...I used them when I made games with game maker. But I still want to use the dll idea but, rrr this is making me mad!
    No, you missed my point. What I mean is use global functions in the DLL, not a class. In other words, do the stuff that the tutorial on flipcode says

    I am running into a problem on my own though. I tried DLL-izing my Huffman compression code, and got the DLL and .LIB file. Any idea on how to link the .LIB though, or does it have to go into the compiler/linker's library folder?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  13. #28
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    lol linking the lib? Do you mean by adding anouther #include <dll.h> ? Because if so that is how, and if so I feel smart helping a smarter then me person!

    But anyways...this is tiking me off. I sorta don't got a HTML editor yet (me and my mom might go in on a 50 dallor one soon) so I don't got project Chi Chi website yet. But I sorta wanna get Project Chi Chi some were soon. instead of the same old trial and error.

  14. #29
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    To answer some questions:

    I am running into a problem on my own though. I tried DLL-izing my Huffman compression code, and got the DLL and .LIB file. Any idea on how to link the .LIB though, or does it have to go into the compiler/linker's library folder?
    Just include the header file in your code, and link to the .lib file. In MSVC++, go to project->settings->link tab-> add your .lib to the modules there.

  15. #30
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Ok can anyone explain on how to put functions in this?
    Just add member functions like you would to any other class. Since the whole class is exported, you dont have to do anything special.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. read from .txt file & put into array?
    By slow brain in forum C Programming
    Replies: 6
    Last Post: 02-25-2003, 05:16 AM
  3. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM