Bonjour,

j'ai vu des tas de choses sur le web, mais tout ce que j'ai essayé ne fonctionne pas.

Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Public Class frmMain
    Declare Function cdtInit Lib "cards.dll" (ByRef width As Integer, _
        ByRef height As Integer) As Boolean
    Declare Function cdtDraw Lib "cards.dll" (ByVal hdc As IntPtr, _
        ByVal x As Long, ByVal y As Long, ByVal card As Long, _
        ByVal type As Long, ByVal color As Long) As Boolean
    Declare Sub cdtTerm Lib "cards.dll" ()
 
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cdtInit(pic.Width, pic.Height).ToString()
    End Sub
 
    Protected Overrides Sub Finalize()
        cdtTerm()
        MyBase.Finalize()
    End Sub
 
    Private Sub but_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles but.Click
        cdtDraw(pic.Handle, 50, 30, 5, 1, 1)
    End Sub
End Class
pic est un PictureBox,
btn est un Button.

A l'appel de la fonction cdtDraw, j'ai l'exception suivante:
PInvokeStackImbalance was detected
A call to PInvoke function 'TexasStats!TexasStats.frmMain::cdtDraw' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Tout ça me dépasse... Quelqu'un pour m'éclairer ?

Merci !
Vonotar