Results 1 to 12 of 12

Thread: using cards.dll

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123

    Question

    I am trying to write a video poker game in MFC for my windows programming class. I would like to use the cards.dll file in windows so I dont have to draw all the cards and stuff.

    I already have cards.dll (32 bit) with my OS of course. I also have the header file with the function prototypes and #defines for the 4 cards.dll functions. I used instructions i got off the web to make a library file from the cards.dll and linked it up to the project settings. When i try to call the cards.dll functions i get a link error saying i have unresolved externals for the called cards.dll functions. I have tried everything, still get the same error!!!!

    here is what i am using to make the cards.lib file:

    buildlib.bat
    ---------------
    DUMPBIN /EXPORTS c:\winnt\system32\cards.dll > cards.dmp
    start notepad cards.dmp
    notepad cards.def
    LIB /MACHINE:IX86 /VERBOSE /SUBSYSTEM:WINDOWS /DEF:cards.def


    cards.def
    -------------
    EXPORTS WEP@1
    EXPORTS EXPORTS cdtAnimate@20=cdtAnimate@2
    EXPORTS EXPORTS cdtDraw@24=cdtDraw@3
    EXPORTS EXPORTS cdtDrawExt@32=cdtDrawExt@4
    EXPORTS EXPORTS cdtInit@8=cdtInit@5
    EXPORTS EXPORTS cdtTerm@0=cdtTerm@6

    I am using Windows 2000 and Visual C 6.

    Can someone please help me?? Thanks
    Attached Files Attached Files

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Why are you trying to make a static library? Why not just use the DLL?
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123
    how would I just use the dll??

    I dont know what settings to use and what to include in the project to enable me to use the cards.dll functions....???

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    BOOL __stdcall cdtInit(int FAR *pdxCard, int FAR *pdyCard);
    BOOL __stdcall cdtDraw(HDC hdc, int x, int y, int cd, int md, DWORD rgbBgnd);
    BOOL __stdcall cdtDrawExt(HDC hdc, int x, int y, int dx, int dy, int cd, int md, DWORD rgbBgnd);
    BOOL __stdcall cdtAnimate(HDC hdc, int cd, int x, int y, int ispr);
    VOID __stdcall cdtTerm(VOID);
    Right, those are the prototypes you need, altered slightly from those you gave. Use LoadLibrary to get a handle to cards.dll, and use function pointers to get the location of those functions Excuse me being brief but I can't stay long
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123
    thanks for the input parksie, but i still can't quite get it.

    here is my attempt to call the cdtInit function:

    BOOL __stdcall DllFunc;
    HINSTANCE hDLL;
    int xCard, yCard;

    hDLL = LoadLibrary("cards.dll");

    if (hDLL != NULL)
    {
    DllFunc = (BOOL __stdcall)GetProcAddress(hDLL,"cdtInit");
    if (!DllFunc)
    {
    FreeLibrary(hDLL);

    break;
    }
    else
    {

    DllFunc(&xCard, &yCard);
    }
    }

    and here are the errors i get:

    C:\TEMP\testt\testt.cpp(168) : warning C4229: anachronism used : modifiers on data are ignored
    C:\TEMP\testt\testt.cpp(176) : warning C4229: anachronism used : modifiers on data are ignored
    C:\TEMP\testt\testt.cpp(186) : error C2064: term does not evaluate to a function

    can you help? thanks alot

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You've just been murdered viciously at the hands of function pointers.
    Code:
    typedef BOOL (__stdcall *PFNINITFUNC)(int *, int *);
    
    void yourfunction() {
        PFNINITFUNC cdtInit;
        HINSTANCE hDLL;
    
        int xCard, yCard; 
    
        hDLL = LoadLibrary("cards.dll"); 
    
        if(hDLL) { 
            cdtInit = (PFNINITFUNC)GetProcAddress(hDLL,"cdtInit");
            if(!cdtInit)
                FreeLibrary(hDLL); 
    
            (cdtInit)(&xCard, &yCard);
        } else {
            // Could not load library
        }
    }
    ...or something similar
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123
    thank you SO MUCH. I actually had tried something close to what you just posted, but had some parens and *'s in the wrong place.

    i've already expanded it to get a card on the screen and it works great.

    thanks again.

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Even I still have to look up the exact syntax of function pointers
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Unhappy Can someone explain this cards.dll getting picture concept 2 me please.

    I'm the annoying person who hears half a conversation, and has to know more. How does the cards.dll work. And how did who tells me how it works, find out how it workz?? Thanx
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Cards.dll is a DLL that comes with Windows that basically has one purpose - draw playing cards
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Unhappy Kule. How do I use it.

    I got the drift of that from the messages already posted. But like how does it do what it doez. And how do I call it, and use it. Thanx
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  12. #12

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123
    how does it do what it does?
    - the dll has a set of 5 functions, if you load the dll into your windows program you can call these functions. download the cards.h file in this post to see what the functions do.

    how do you call it?
    - parksie graciously helped me out with this one. see his code in this post.

    if you still cant get it, email me at [email protected]. ill send you some code to help u out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width