0

I am trying to import a delphi dll and use its method.

Here is the delphi method signature:

function CALinkEncode(SubscriberID, MailshotID, LinkID: DWORD; sCode: PWideChar): HRESULT; stdcall; 

Here is the c# code to import the dll and use the function.

    [DllImport(@"Decoder.dll", CharSet = CharSet.Ansi)]
    static extern string CALinkEncode(
        int SubscriberID,
        int MailshotID,
        int LinkID
    );

    public static string CALinkDecodeString(int cas, int cam, int cal)
    {
        string retvalptr = CALinkEncode(cas, cam, cal);

        return retvalptr;
    }

Please help.

1 Answer 1

4

You are missing a parameter, have the wrong return type, and have the wrong character set. It should be:

[DllImport(@"Decoder.dll", CharSet = CharSet.Unicode)]
static extern uint CALinkEncode(
     uint SubscriberID,
     uint MailshotID,
     uint LinkID,
     string sCode
 );

I've assumed the string parameter is an input parameter. If not, then you need to declare it as StringBuilder and pass a StringBuilder instance with sufficient capacity for the output buffer.

.

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.