Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Delphi Dlls in C#

Delphi Dlls in C#

Scheduled Pinned Locked Moved C#
csharpdelphihelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dave Shaw
    wrote on last edited by
    #1

    Hi, I have a Delphi 6 DLL that I need to run from C#.Net 2.0. I have some problems with it though. Here Goes: The Delphi Decalration is : function M_Login(ip : PChar; port : LongInt; uci : PChar; vol : PChar; pass : PChar; user : PChar) : LongInt; stdCall; And the C# Declaration is : [DllImport("iMSMAPI.DLL", CallingConvention = CallingConvention.StdCall, CharSet=CharSet.Ansi)] private static extern Int64 M_Login(string ip, Int64 port, string uci, string vol, string pass, string user); This gives me an AccessViolationException at RunTime when I call M_Login. I can Change the Delphi Declaration to expect Strings instead of PChars, this avoids the AccessViolationError, but this causes the values passed to the Delphi DLL to be incorrect. i.e. contain characters that the C# Application did not pass. I passed the value "127.0.0.1" as the ip parameter in C# and when I inspected the ip parameter in Delphi it was '1'#0'2'#0'7'#0'.'#0'0' . Can anyone help. Thanx! Dave Shaw History admires the wise, but elevates the brave. - Edmund Morris

    S 1 Reply Last reply
    0
    • D Dave Shaw

      Hi, I have a Delphi 6 DLL that I need to run from C#.Net 2.0. I have some problems with it though. Here Goes: The Delphi Decalration is : function M_Login(ip : PChar; port : LongInt; uci : PChar; vol : PChar; pass : PChar; user : PChar) : LongInt; stdCall; And the C# Declaration is : [DllImport("iMSMAPI.DLL", CallingConvention = CallingConvention.StdCall, CharSet=CharSet.Ansi)] private static extern Int64 M_Login(string ip, Int64 port, string uci, string vol, string pass, string user); This gives me an AccessViolationException at RunTime when I call M_Login. I can Change the Delphi Declaration to expect Strings instead of PChars, this avoids the AccessViolationError, but this causes the values passed to the Delphi DLL to be incorrect. i.e. contain characters that the C# Application did not pass. I passed the value "127.0.0.1" as the ip parameter in C# and when I inspected the ip parameter in Delphi it was '1'#0'2'#0'7'#0'.'#0'0' . Can anyone help. Thanx! Dave Shaw History admires the wise, but elevates the brave. - Edmund Morris

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Just guessing here, but I think it's the different sizes of char that is the problem. A char is two bytes in C# and I *think* it's not getting interpreted that way in Delphi. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      D 1 Reply Last reply
      0
      • S S Senthil Kumar

        Just guessing here, but I think it's the different sizes of char that is the problem. A char is two bytes in C# and I *think* it's not getting interpreted that way in Delphi. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        D Offline
        D Offline
        Dave Shaw
        wrote on last edited by
        #3

        Thanks Senthil, I have now overcome this problem, however. I am now getting a BroadcastEventWindow.2.0.0.0.33 when I close my application. I am then getting RunTime Error 217 once then getting RunTime Error 216 followed by 'The Memory Could not be "Read"' message in a Continuous Loop until I Kill my Application. Any Ideas? Thanks. Dave Thanx! Dave Shaw History admires the wise, but elevates the brave. - Edmund Morris

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups