Results 1 to 2 of 2

Thread: Accessing a Pascal DLL in VB6

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006

    Accessing a Pascal DLL in VB6

    Hello All.

    I am trying to access a function within a DLL written in Pascal, but when I try to use it a GPF in VB6 occurs and exits the VB IDE.

    This is from the documentation of the DLL written in Pascal:

    procedure r8b_execute (InFileName, OutFileName: PChar OutRate, OutBitDepth, OutQuality, Preallocate: LongInt
    var CancelFlag: LongInt; Callback: TR8BCallback; p: Pointer var err: TR8BError); cdecl; external 'r8b.dll';

    err is a structure that will hold error information occured:
    TR8BError =
    packed record
    WasError: Boolean;
    ErrMsg: array [0..127] of Char;

    Callback is an address of the callback procedure, defined as:
    TR8BCallback = procedure (Position, Max: LongInt; p: Pointer); cdecl;

    That is, if Callback <> nil, r8b_execute periodically calls this procedure
    signalling the progress.

    Okay, here is my VB 6 (unsuccessful) code

    Private Declare Function r8b_execute Lib "r8b.dll" (ByVal InFilename As String, ByVal OutFileName As String, ByVal OutRate As Long, ByVal OutBitDepth As Long, ByVal OutQuality As Long, ByVal Preallocate As Long, ByRef CancelFlag As Long, ByRef Callback As TR8BCallback, ByRef Pointer As Long, ByRef err As TR8Error)

    Public Type TR8BCallback
    Position As Long
    Max As Long
    xPointer As Long
    End Type

    Public Type TR8Error
    WasError As Boolean
    msg As String
    End Type

    Later in a Sub...

    Dim xCallback As TR8BCallback
    Dim xCancelFlag As Long
    Dim xError As TR8Error
    Dim xPointer As Long

    xCancelFlag = 0&
    r8b_execute "f:\CT1.wav", "f:\ct1out.wav", 0.2, 16&, 1&, 0&, xCancelFlag, xCallback, xPointer, xError

    The author of the DLL says it works fine from C/C++ apps and the error must have something to do with my declarations.

    I have been trying to make this work function way too long. ANY ideas or assistance is greatly appreciated.

    Thanks, Mike

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2006

    Re: Accessing a Pascal DLL in VB6


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