I am communicating with a Delphi DLL and I reference it by this
Public Declare Ansi Function GetERPStatus Lib "C:\Program Files\EasyCheck\EasyCheckLib.dll" Alias "GetERPStatus" (ByVal RFID As String, ByVal NLISID As String, ByVal PIC As String, ByVal StateCode As String, ByVal ProcType As String, ByRef Status As Byte, ByVal MaxLength As Integer) As Boolean
The "Status" variable is passed by reference so that the DLL can write to the variable.
If I do it as above then it will work but returns a number "79" dont think its that important, then funny things start happening, such as an exception in a different part of my code that isnt even called at any point.
I suspect It wirtes to this byte, but doesnt have enough space and writes over other things in memory
Here is the documentation that came with the DLL
If successful the lpStatus parameter will contain a string on the exception. These will be comma ‘,’ delimited for each exception and within the exception the fields are separated by the tilde ‘~’ character, as follows;
If i use other data types in the status variable then it just crashes
I have used the object data type and it returns this error
Additional information: Specified OLE variant is invalid.
If i use a string data type it just returns
Additional information: Object reference not set to an instance of an object.