Results 1 to 7 of 7

Thread: Call Delphi Assembly from VB.NET

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    3

    Call Delphi Assembly from VB.NET

    Hello Everyone:
    I was hoping there was someone who has some Delphi knowledge that could help with calling a Delphi developed assembly from VB.net. The Delphi assembly is not a com object but only a dll with one exported function. It is supposed to be an AES module in which you pass a password and its encrypted equivilant and the module pases back true if they match or false if not.

    I have a database with usernames/ AES encrypted passwords that were built by a Delphi program. I contacted the original programmer for the keys to decrypt these passwords, but he was unable to determine what the keys were so he built me this function.

    The problem I am having is either I get false for matches or I get "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

    I recieved two versions. The first one took two strings and passed back a boolean:

    function checkEqual(clearString, encryptedString: string): boolean;

    I found out that he made the strings short strings on the Delphi end which may be a problem on the VB.NET end.

    The second assrmbly I recieved was because I could not get the first to work. It took two arrays of char and passed back a boolean.

    I am currently tring the one with the arrays of char and have it defined like:

    <DllImport("C:\vaebEncCheck.dll", EntryPoint:="checkEqual", SetLastError:=True, CharSet:=CharSet.Unicode, _
    ExactSpelling:=True, CallingConvention:=CallingConvention.Winapi)> _
    Public Shared Function checkEqual(ByVal clearString As Char(), ByVal encryptedString As Char()) As Boolean

    End Function

    I hope someone could help me out with this as I have tried everything I could and am clueless.

    Thanks,

    Joe

  2. #2
    New Member
    Join Date
    Feb 2008
    Posts
    3

    Re: Call Delphi Assembly from VB.NET

    hi joescho
    i wish i can help you but im stuck at the same problem just like you
    do u still get the error? if not plz help me out
    im using vb.net 2008 and trying to call some Delphi dll but the same error hit me all the time :|
    what is the use of a DllImport statement any way??
    thx

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    3

    Re: Call Delphi Assembly from VB.NET

    I never did figure it out. I ended up going another way. The DLLImport allows you to bring in an assembly into your program, and declare the procedure or function you're trying to use so that the compiler can do the typing for the input/output parameters so you don't blow the stack when you call it.

    I figure that there's not that many people who have tried to do this, so there's not an abundance of information out there for doing this.

    You're either going to have to either rewrite the functionality of the Delphi assembly into your own code, or go completely Delphi for your project.

  4. #4
    New Member
    Join Date
    Feb 2008
    Posts
    3

    Re: Call Delphi Assembly from VB.NET

    Quote Originally Posted by joescho
    The DLLImport allows you to bring in an assembly into your program, and declare the procedure or function you're trying to use so that the compiler can do the typing for the input/output parameters so you don't blow the stack when you call it.
    could u explain more what u did exactly??
    maybe some code lines

    Quote Originally Posted by joescho
    go completely Delphi for your project.
    thats what i had to do
    and i spent 2 months learning Delphi but vb 2008 is much better! and i have no problem converting all the work into vb but i must get rid of the stupid dll thing first
    thx again for ur response
    have a nice day

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    3

    Re: Call Delphi Assembly from VB.NET

    I don't think I still have the code. It was a while back. If I remember correctly, I just had a DLLImport line like in my original post, then had a call in my code to execute the external procedure which is all you should have to do.

    I think the problem lies in how either Delphi handles parameters, or how .NET handles parameters. If it was a problem with the declaration in the assembly, then .NET wouldn't be able to find the procedures in the DLL. Since its giving a corrupt memory error, the memory must be getting mangled either by the number of bytes on the stack, or the Delphi assembly is accessing a part of memory that .NET isn't expecting. Just my 2 cents.

  6. #6
    New Member
    Join Date
    Feb 2008
    Posts
    3

    Re: Call Delphi Assembly from VB.NET

    i have the source code of the dll but i dont know what to change in the fn
    any way thx a lot for responding

  7. #7
    New Member
    Join Date
    May 2009
    Posts
    1

    Re: Call Delphi Assembly from VB.NET

    have a look at this link

    there is a download with an example


    http://www.blong.com/Conferences/Bor...op.htm#PInvoke

    regards

    ian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width