4

私は現在、IT会社で働いています。彼らはClarionを使用してソフトウェアを作成し、そのソフトウェアには、データベースから多くの値を再計算するDLLがあります。このDLLをC#プロジェクトから呼び出す必要があります。私はそれが機能せずにすべてを試しました。

私のコードは以下の通りです:

public partial class Form1 : Form
{
    [DllImport("EPNORM.dll", EntryPoint = "MyRecalcualate@FlOUcOUcOsbOUc")]
    public static extern void MyRecalcualate(System.Int64 myPtr, System.Int64 myLong, CWByte myByte);

    [DllImport("User32.dll")]
    public static extern Boolean MessageBeep(UInt32 beepType);

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        System.Int64 myPtrTemp = 1234;
        System.Int64 myLongTemp = 5678;
        System.Byte myByteTemp = 88;

        try
        {
            MyRecalcualate(myPtrTemp, myLongTemp, myByteTemp);
            bool messagebeep = MessageBeep(1);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        finally
        {
            MessageBox.Show("Successful");
        }
    }
}

問題は、ブレークポイントを使用して呼び出すと、MyRecalcualateメソッドに表示されなくなり、2秒後にブロックに到達finalllyし、DLLから何も実行せずに再表示されることです。これは、DLLメソッドに修正が必要なものがあるためですか、それとも呼び出しを間違って行っているためですか?

以下の呼び出しのパラメーターは次のとおりです。MyRecalculate(LONG、LONG、BYTE)

MyRecalcualate      PROCEDURE (MyStringPtr, MyLong, MyByte) ! Declare Procedure
LOC:CString         CSTRING(255)
LOC:Byte            BYTE
CODE
! clear completely LOC:CString with null values
LOC:CString = ALL('<0>', SIZE(LOC:CString))

! load string value, byte by byte, from memory address passed (MyStringPtr) and put into LOC:CString
I# = 0
LOOP
     PEEK(MyStringPtr + I# , LOC:Byte)
     IF LOC:Byte = 0 THEN BREAK END
     LOC:CString[I# + 1] = CHR(LOC:Byte)
     I# += 1
END

MESSAGE('MyString value is:||' & CLIP(LOC:CString))
MESSAGE('MyLong value is:||' & MyLong)
MESSAGE('MyByte value is :||' & MyByte)

これは、契約開発者が私にメールで送ったパラメータと、VB.NETでの呼び出し方法のスクリーンショットです。VB.NETコード:http://imageshack.us/photo/my-images/269/callfromvisualbasictocl.jpg/ PARAMETERS IN CLARION : http: //imageshack.us/photo/my-images/100/asdxg.jpg/

4

1 に答える 1

2

最初のパラメーターは、ヌル終了文字ストリングへのポインターです。Int64ランダムな値を渡すことはできません。したがって、ピンボークは次のようになります。

[DllImport("EPNORM.dll", EntryPoint = "MyRecalcualate@FlOUcOUcOsbOUc")]
public static extern void MyRecalcualate(string myPtr, int myInt, byte myByte);

2番目のパラメータであるClarionLONGは32ビット整数だと思います。つまりint、C#側です。さらに、クラリオン側の呼び出し規約を再確認する必要があります。stdcallそれがあなたのC#が使用しているものであると確信していますか?

于 2012-05-16T13:11:00.080 に答える