Announcement

Collapse
No announcement yet.

DLL Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mike Doty
    replied
    Agree with Jose. Here would be the code in VB. Got rid of ALIAS using all upper case.
    Code:
    Option Explicit
    Private Declare Function PT_SETBOARDWINDOW Lib "TEST.DLL" (ByVal hwnd As Long, ByVal resize As Long, ByVal boardnum As Long) As Long
    Private Sub Form_Load()
      Dim L As Long, resize As Long, boardnum As Long
      L = PT_SETBOARDWINDOW(hwnd, resize, boardnum)
    End Sub
    Last edited by Mike Doty; 27 Jun 2009, 12:50 PM.

    Leave a comment:


  • Michael Mattias
    replied
    Besides, you can't export a function compiled as a STDCALL and it expect to work if the caller thinks (via its DECLARE or equal) that it is CDECL!!!

    (I believe the code for a stack fault GPF is 0x0000000A)

    MCM

    Leave a comment:


  • José Roca
    replied
    If so, then can someone tell me why this function returns a 'bad dll calling convention' in VB6?
    Because VB6 doesn't understand the PB syntax. Just remove SDECL. STDCALL is the default calling convention used by PB if you don't specify one.

    Leave a comment:


  • Guest's Avatar
    Guest started a topic DLL Question

    DLL Question

    Hello everyone. I'm new to PB and have a quick question about creating a stdcall wrapper DLL for an existing cdecl DLL.

    Ok, so I have a function in a cdecl DLL defined in its documentation as such:

    int SN_SetBoardWindow(
    HWND hwnd,
    BOOL bResize,
    int board
    );

    I create a new PB DLL and declare this function as:

    DECLARE FUNCTION SN_SetBoardWindow CDECL LIB "mid2250.dll" ALIAS "SN_SetBoardWindow" (BYVAL hwnd AS DWORD, BYVAL resize AS LONG, BYVAL boardnum AS LONG) AS LONG

    I then create a new function in my new DLL:

    FUNCTION PT_SetBoardWindow SDECL ALIAS "PT_SetBoardWindow" (BYVAL hwnd AS LONG, BYVAL resize AS LONG, BYVAL boardnum AS LONG) EXPORT AS LONG
    FUNCTION = SN_SetBoardWindow(CDWD(hwnd),resize,boardnum)
    END FUNCTION

    Am I on the right track in using the declare and a new sdecl function? If so, then can someone tell me why this function returns a 'bad dll calling convention' in VB6?

    Thanks in advance for any tips/suggestions/help that anyone may give...


    Jon
Working...
X