Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cards.Dll - Just For Fun
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Cards.Dll - Just For Fun
Divers
Thread ID:
01473654
Message ID:
01473654
Vues:
118
I thought I'd try to use the Cards.Dll that ships with Windows to draw a card on a C# WinF/orm.

The Object Explorer shows this method in Cards.DLL:
cards.cardsdll.drawcard(System.IntPtr, int, int, int, int, int)
So I wrote this:
public class DeckOfCards
{
    [DllImport("cards.dll")]
    private static extern bool drawcard(ref IntPtr handle, ref int top, ref int left, 
           ref int width, ref int height, ref int card);

    public DeckOfCards()
    {
    }

    public bool DrawACard(IntPtr canvas, int top, int left, int width, int height, int card)
    {
        return drawcard(ref canvas, ref top, ref left, ref height, ref width, ref card);
    }
}
Then I attempted to use it like this:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

            DrawCard();
    }

    private void DrawCard()
    {
        DeckOfCards Deck = new DeckOfCards();

        IntPtr hdc = this.Handle;

        Deck.DrawACard(hdc, 10, 10, 100, 50, (int)Ranks.Five * 4 + (int)Suits.Clubs);

    }
}
It dies in the DrawACard method of my class with "Unable to find an entry point named 'drawcard' in DLL "cards.dll'.

As I have little to no experience working with COM in .Net (yet) I'm hoping someone can see what's wrong.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform