Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Not really a question, but +1 :). Commented Nov 12, 2010 at 9:57
  • I'm not familiar with delphi but know if is possible to convert it to COM its easy to use it in c#, I made a little search and find some resource which is about delphi and COM relation here: delphi.about.com/library/weekly/aa122804a.htm Commented Nov 12, 2010 at 10:05
  • 6
    You should rephrase your question to say "What is the proper way to use a Delphi DLL from a C# .NET application?" and then answer yourself with the rest of your post. See stackoverflow.com/faq (You may answer your own question) and here: meta.stackexchange.com/questions/12513/… Commented Nov 12, 2010 at 10:36
  • 8
    You need to be very careful here. Delphi strings are reference counted; the refcount of s in DelphiFunction will be zero at the end of the function, so the memory that is used by s will be returned to the memory allocator, and potentially be used (and overwritten) by something else after DelphiFunction returns before the C# caller can fetch the content. When that happens, all sorts of havoc will occur. In a multi-threaded situation (especially on multi-core systems) that can be really soon. Commented Nov 12, 2010 at 12:13
  • Jens - Thanks for the information. I wondered if I was doing this right. -Dan
    – Dan Thomas
    Commented Nov 14, 2010 at 14:28