Please use the new COM API object instead. It is much easier than the code below. 
For those who still want to use a real API.DLL see the examples below.

Copy the API.DLL to the \system32 directory so VB finds the library. Do not forget to rewrite the DLL everytime you install new Merak version.

Start a VB project, the type is not important, but it is probably easier to test as you go if you create an EXE. Add a module to this project and then add the following code into that module:

Public Enum VarTypes
    V_Bool = 1
    V_Long
    V_String
End Enum

Public Enum ResultCodes
  S_OK = 0

  E_FAILURE = -1
  E_LICENSE = -2
  E_PARAMS = -3
  E_PATH = -4
  E_CONFIG = -5
End Enum

Public Enum DomainSetting
  D_Description = 0
  D_Type
  D_DomainValue = 3
  D_PostMaster
  D_AdminForward
  D_UnknownUsersForward
  D_UnknownForwardTo
  D_InfoToAdmin

End Enum

Public Enum UserSetting
  U_Type = 0
  U_AntiSpamIndex
  U_Name
  U_Alias

  U_Mailbox = 16
  U_AccountDisabled
  U_AccountValid
  U_AccountValidTill
  U_CheckVirus
  U_AllowRemote
  U_ValidityReport
  U_ValidityReportDays
  U_NTPassword
  U_IMAP
  U_IMAPMailbox
  U_MaxMessageSize
  U_DontShowMessages
  U_AnyPassword
  U_ETRN
  U_DeleteExpire
  U_NULL
  U_Password
  U_NTPasswordValue
  U_DomainAdminIndex
  U_DomainAdmin
  U_MailBoxPath
  U_Admin
  U_MaxBox
  U_MaxBoxSize
  U_ForceFrom
  U_Respond
  U_OnlyLocalDomain
  U_UseRemoteAddress
  U_ForwardTo
  U_RespondWith
  U_MailIn
  U_MailOut
  U_ValidReport
  U_DeleteOlder
  U_DeleteOlderDays
  U_ForwardOlder
  U_ForwardOlderDays
  U_ForwardOlderTo
  U_RemoteAddress
  U_ForceFromAddress
  U_MegabyteSendLimit
  U_NumberSendLimit
  U_NoMailList
  
  E_Application = 80
  E_Parameters
  E_ExecForwardCopy

  M_OwnerAddress = 112
  M_CopyToOwner
  M_DigestConfirmed
  M_MailingListFile
  M_ListServer
  M_SendToSender
  M_SubListFile
  M_SendAllLists
  M_HeaderFile
  M_FooterFile
  M_Moderated
  M_ModeratedPassword
  M_DenyEXPNList
  M_MaxList
  M_MaxListSize
  M_SetFromTo
  M_SetFromToValue
  M_HelpFile
  M_MembersOnly
  M_ReplyTo
  M_SwitchFields
  M_AddToSubject
  M_JoinR
  M_LeaveR
  M_ListsR
  M_WhichR
  M_ReviewR
  M_ListSubject
  M_ListSender
  M_ServerModerated

  S_MailAddress = 160
  S_SMSIntoSubject
  S_Size
  S_SendTo
  S_SendFrom
  S_SendSubject
  S_SendBody
  S_SendDateTime
  S_Send
  S_SMSForwardCopy
  S_SkipAttach
  S_SMSSender
  S_SMSCount 
  S_SMSFilterFile

  R_Activity = 192
  R_ActivityValue
  R_FilterFile  
  R_ExternalFilter 
  R_ExternalFilterFile 
  R_ExternalDomain 
  R_SaveTo 
  R_ExternalFilterType
End Enum

Public Const BUFFER_SIZE As Integer = 4192

''' Misc Functions

Public Declare Function Init Lib "api" (ByVal Directory As String) As Long

''' Domain Functions

Public Declare Function GetDomainCount Lib "api" () As Long

Public Declare Function GetDomainList Lib "api" (ByRef List As Byte, ByVal Size As Long) As Long

Public Declare Function GetDomainName Lib "api" (ByVal Index As Long, _ByRef Name As Byte, ByVal Size As Long) As Long

Public Declare Function GetDomainIndex Lib "api" (ByVal Name As String) As Long

Public Declare Function LoadDomain Lib "api" (ByVal Index As Long, ByRef Buffer As Byte, _ByVal Size As Long) As Long
    
Public Declare Function SaveDomain Lib "api" (ByVal Index As Long, ByRef Buffer As Byte, _ByVal Size As Long) As Long

Public Declare Function AddDomain Lib "api" (ByVal Name As String, ByRef Buffer As Byte, _ ByVal Size As Long) As Long

Public Declare Function DeleteDomain Lib "api" (ByVal Index As Long) As Long

Public Declare Function GetDomainSetting Lib "api" (ByRef Buffer As Byte, ByVal Size As Long, _ByVal Setting As DomainSetting, ByRef FResult As Byte, ByVal ResultSize As Long) As Long

Public Declare Function SetDomainSetting Lib "api" (ByRef Buffer As Byte, ByVal Size As Long, _ByVal Setting As DomainSetting, ByRef FResult As Byte, ByVal ResultSize As Long) As Long

''' User Functions

Public Declare Function GetUserList Lib "api" (ByVal Domain As String, _ByRef List As Byte, ByVal Size As Long) As Long

Public Declare Function GetUserCount Lib "api" (ByVal Domain As String) As Long

Public Declare Function GetUserIndex Lib "api" (ByVal Domain As String, ByVal Alias As String) As Long

Public Declare Function LoadUser Lib "api" (ByVal Domain As String, ByVal Index As Long, _ByRef Buffer As Byte, ByVal Size As Long) As Long
    
Public Declare Function SaveUser Lib "api" (ByVal Domain As String, ByVal Index As Long, _ByRef Buffer As Byte, ByVal Size As Long) As Long

Public Declare Function GetUserSetting Lib "api" (ByRef Buffer As Byte, ByVal Size As Long, _ByVal Setting As UserSetting, ByRef FResult As Byte, ByVal ResultSize As Long) As Long

Public Declare Function SetUserSetting Lib "api" (ByRef Buffer As Byte, ByVal Size As Long, _ByVal Setting As UserSetting, ByRef FResult As Byte, ByVal ResultSize As Long) As Long

Public Declare Function AddUser Lib "api" (ByVal Domain As String, ByRef Buffer As Byte, _ByVal Size As Long) As Long

Public Declare Function DeleteUser Lib "api" (ByVal Domain As String, ByVal Index As Long) As Long

Public Declare Function AuthenticateUser Lib "api" (ByVal Mailbox As String, ByVal Password As String, ByVal IP As String, ByRef DomainIndex As Long, ByRef FResult As Byte, ByRef ResultSize As Long) As Long

When making any call to the Merak API you must initialize the API first by calling
the Init function defined above. Here is how to make that call:

Private Sub Form_Load()
  Debug.Print Init("d:\Merak\"**)
End Sub

* Note that I'm basing this on a typical VB EXE Project
** This path is your Merak Directory

Contrary to how VB works, if Init returns a zero then you have initialized the API correctly.
To get an idea of what the other return codes mean take a look at results codes enum listed above.

Get Domain List

Let's start off with a fairly easy task, getting a list of the domains. This will provide 
a good example of how Merak uses byte arrays which are not typically used much in VB. To 
get the list of domains we can use the following code:

Private Sub Form_Load()

    Dim lNum As Long
    Dim lMax As Long
    Dim sString As String
    Dim asList(1 To 1024) As Byte
    
    ''' remember that Merak returns 0 for success
    If Not Init("d:\Merak\") Then
    
        lMax = GetDomainList(asList(1), 1024)
        
        For lNum = 1 To lMax
            If asList(lNum) <> 0 Then
                sString = sString & Chr$(asList(lNum))
            Else
                Debug.Print sString
                sString = ""
            End If
        Next lNum
        
    End If

End Sub

Make sure that you change the path in the Init call to the proper path in your system.
When the asList variable gets filled by the GetDomainList call, it will insert a zero for 
breaks between multiple arrays and it will insert two zeros at the end of the list. Once 
these bytes have been converted to characters this would look something like this:

domainA0domainB0domainC00

That is why each byte is checked to see if it is greater than zero. If it is a zero it is
a separator, if there are two zeros in a row that is the end of the list. The function itself
returns to us the number of bytes that have been put into the array. An easy way to handle this
would be to cut off the last two bytes and then split the string.

Loading Domains and Users

In order to make changes to Domains and Users you first have to load their settings byte array
which you can then modify to make changes. Loading is a fairly simple task and works the same for
both Domains and Users.

Private Sub Form_Load()

    Dim lIndex As Long
    Dim abBuffer(1 To BUFFER_SIZE) As Byte
    
    ''' remember that Merak returns 0 for success
    If Not Init("d:\Merak\") Then
    
        lIndex = GetDomainIndex("yourdomain.com")
        Debug.Print LoadDomain(lIndex, abBuffer(1), BUFFER_SIZE)
        
    End If

End Sub

First you need the index, and then you can load the domain/user which fills the buffer variable.

Changing Settings

Once you have loaded a domain or a user you can then make calls to GetSetting and SetSetting. 
One of the hardest parts about this is knowing what type of value a setting uses. Merak uses
three different variable types for the settings-boolean, long, and string. It is important to know
which type of value the system is expecting because of the byte conversion process that is required. 
All boolean types are in fact long integers with the value 0 or 1.
Below are some functions which I use to do the conversions:

Public Function CBytes2Long(ByRef Bytes() As Byte) As Long

    Dim lTemp As Long
    
    lTemp = Bytes(1)
    lTemp = lTemp + (Bytes(2) * 256)
    lTemp = lTemp + (Bytes(3) * 65536)
    CBytes2Long = lTemp

End Function

Public Function CBytes2String(ByRef Bytes() As Byte) As String

    Dim lMax As Long
    Dim lNum As Long
    Dim sTemp As String
    
    lMax = UBound(Bytes)
    
    For lNum = 1 To lMax
        sTemp = sTemp & Chr$(Bytes(lNum))
    Next lNum

    CBytes2String = sTemp

End Function

Public Sub CString2Bytes(ByVal Value As String, ByRef Bytes() As Byte)

    Dim lLen As Long
    Dim lNum As Long
    
    lLen = Len(Value)
    
    ReDim Bytes(1 To lLen) As Byte
    
    For lNum = 1 To lLen
        Bytes(lNum) = Asc(Mid$(Value, lNum, 1))
    Next lNum

End Sub

Public Sub CLong2Bytes(ByVal Number As Long, ByRef Bytes() As Byte)
   
    Bytes(3) = Number \ 65536
    Number = Number Mod 65536
    Bytes(2) = Number \ 256
    Number = Number Mod 256
    Bytes(1) = Number  

End Sub

Once you know that you can convert these values back and forth you can make the calls
to set and get the settings. Here is an example to get and set a user's password:

Private Sub Form_Load()

    Dim lIndex As Long
    Dim abBuffer(1 To BUFFER_SIZE) As Byte
    Dim abOut() As Byte
           
    ''' The size of this array depends on the
    ''' type of variable.
    ''' 1 for boolean
    ''' 4 for long
    ''' 1024 for string
    ReDim abOut(1 To 1024) As Byte
    
    ''' remember that Merak returns 0 for success
    If Not Init("d:\Merak\") Then
    
        lIndex = GetUserIndex("mydomain.com", "myuser")
        Call LoadUser("mydomain.com", lIndex, abBuffer(1), BUFFER_SIZE)
        
        ''' get the user's password
        Call GetUserSetting(abBuffer(1), BUFFER_SIZE, U_Password, abOut(1), UBound(abOut))
        
        Debug.Print CBytes2String(abOut)
        
        ''' set the password
        CString2Bytes "newpass", abOut
        
        Call SetUserSetting(abBuffer(1), BUFFER_SIZE, U_Password, abOut(1), UBound(abOut))
        
    End If

End Sub

Please note that the above code will not change the user's password because we didn't save the 
settings. 

Saving Domains and Users

Once you have made changes to a user or domain's settings you have to save those settings
or else all your changes will be lost. Saving is easy to do.

Private Sub Form_Load()

    Dim lIndex As Long
    Dim abBuffer(1 To BUFFER_SIZE) As Byte
    
    ''' remember that Merak returns 0 for success
    If Not Init("d:\Merak\") Then
    
        lIndex = GetDomainIndex("yourdomain.com")
        Debug.Print SaveDomain(lIndex, abBuffer(1), BUFFER_SIZE)
        
    End If

End Sub

Creating Domains and Users

If you understand everything up to this point then creating domains and uses
should be a fairly simple task for you to do. First of you have to create an empty
buffer array and then set the values you need to set on that user or domain. Once 
your buffer is set with all of your values you will then call AddDomain or AddUser. 
Below is some sample code on how to add a new user to your domain.

Private Sub Form_Load()

    Dim lRet As Long
    Dim abBuffer(1 To BUFFER_SIZE) As Byte
    Dim lNum As Long
           
    ''' initialize the array
    For lNum = 1 To BUFFER_SIZE
        abBuffer(lNum) = 0
    Next lNum
    
    ''' remember that Merak returns 0 for success
    If Not Init("d:\Merak\") Then
        
        ''' you would need to make all of your SetUserSetting calls here
        ''' this code will not work unless you set the settings
        lRet = AddUser("mydomain.com", abBuffer(1), BUFFER_SIZE)
                
    End If

End Sub

Remember that the above code will not work unless you set the user's setting before
calling the AddUser function. I think the minimum settings you can set for a user to
be able to be created it the username, password, and alias. 
