No .lib only .dll?

Started by
1 comment, last by nullsquared 18 years ago

//#include "Code_Log.hpp"
//#include "Code_Pointer.hpp"
//#include "Code_Script.hpp"
#include "Code_Dll.hpp"

#include <iostream>
using namespace std;

int main() {
    Code::DllLibrary Lib;

    Lib.LoadLibrary("SDL.dll");

    if (!Lib) {
        cout << "Couldn't load SDL.dll...";
        return 1;
    }

    void (*pSDL_Delay)(unsigned milliseconds) = NULL;
    pSDL_Delay = Lib.LoadFunction<void (*)(unsigned)> (
        "SDL_Delay"
    );

    if (!pSDL_Delay) {
        cout << "Couldn't load SDL_Delay...";
        return 1;
    }

    for (bool Done = false; !Done;) {
        cout << "How many milliseconds do you want to delay: ";

        unsigned milli = 0;
        cin >> milli;
        cout << "\n";

        pSDL_Delay(milli);
    }
}

I made a little class to load dlls and dll functions.. Nothing fancy, only the basics (just basically load a function...). Now I'm wondering, the SDL_Delay() works fine without linking or anything, just the pointer. Now, does this mean that I can use everything like this? SDL_Init, SDL_Quit, everything? And now come in the structures... Since I won't have them from SDL does that mean that I can make my on struct (completely identicle) and pass it into SDL functions by casting? Just wondering. Thanks.
Advertisement
Yup, you can use it all like that. Thats why DLL's are so powerfull, and why COM works. structs, yeah, unfortunately, you will have to redefine them by hand. Sorry...
Quote:Original post by KaptainKomunist
Yup, you can use it all like that. Thats why DLL's are so powerfull, and why COM works. structs, yeah, unfortunately, you will have to redefine them by hand. Sorry...


Cool stuff! This is sooo interesting!

Thank you. I was more on the side of "will it work" rather than "i will do it" anyways.. It's just that I'm wondering.

To teh opengl gurus, isn't this basically the way to use opengl greater than v.1.1?

This topic is closed to new replies.

Advertisement