2

I am trying to call the method with the following declaration:

extern "C" __declspec(dllimport) int __stdcall CalcDDtable(struct ddTableDeal tableDeal, struct ddTableResults * tablep);

The structs are defined thus:

    struct ddTableDeal {
  unsigned int cards[4][4];
};

struct ddTableResults {
  int resTable[5][4];
};

I am trying to call it thus:

  <DllImport("dds.dll", CallingConvention:=CallingConvention.StdCall)>
Public Shared Function CalcDDtable(ByVal deal As TableDeal, ByRef results As TableResults) As Integer
End Function

Public Function CalculateDeal() As Integer
    Dim tableDeal As TableDeal
    Dim tableResults As TableResults
    Dim cards(3, 3) As Integer
    cards(0, 0) = 32764
    cards(1, 1) = 32764
    cards(2, 2) = 32764
    cards(3, 3) = 32764
    tableDeal.Cards = cards

    Dim results(4, 3) As Integer
    tableResults=new TableResults
    tableResults.Results = results

    Dim errorCode = CalcDDtable(tableDeal, tableResults)

    Return errorCode
End Function

End Class

Public Structure TableDeal
    Dim Cards(,) As Integer
End Structure

Public Structure TableResults
    Dim Results(,) As Integer
End Structure

The structs should both be twodimensional arrays with indexes of 4,4 and 5,4 respectively. The second one is an out parameter.

Where am I going wrong?

For those who want to know:this is the double dummy solver .dll written by Bo Haglund

4
  • Please give the C++ declaration of the two structs. Also why are you writing Dim results(4, 4) if the dimensions are (5, 4)? Commented Jun 23, 2011 at 21:55
  • @ David Heffernan: I edited the question. Commented Jun 23, 2011 at 22:09
  • Does your code really set tableResults.Results to point to the results array and then set tableResults to point to a new Tableresults instance? You'll pass a reference with Results set to nothing if you do that. Commented Jun 24, 2011 at 0:00
  • @ Frank Boyne: No I wasn't, was I? ;-) Commented Jun 24, 2011 at 5:46

1 Answer 1

1

The answer can be found here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.