Sharp Code

Code has never been this sharp!

  Home  |   Contact  |   Syndication    |   Login
  23 Posts | 0 Stories | 58 Comments | 0 Trackbacks

News

.NET Developer who is now exploring the world of react.

Archives

Post Categories

Blogs!

I guess i found out the hard way but better than never finding out :D

I recently had to make an example program in C# using the .NET 2.0 framework to call a function from a Delphi Dll. The function definition was as follows...

function EncryptDoc(Password, FilePath, LaunchFile, OutputFile : WideString) : LongBool; stdcall;

But when i was calling the function like so...

[DllImport("Encrypter.dll", CallingConvention = CallingConvention.StdCall)]
public static extern bool EncryptDoc(string PassWord, string FilePath, string LaunchFile, string OutputFile);

I was receiving an AccessViolationException, anyway i decided to have all four parameters changed to the PChar data type and then recompiled. After this there was no longer an error and everything worked perfectly fine :)

So in conclusion PChar is the Delphi equivalent to the System.String in .NET, i was just wondering if anyone had info on what the equivalent of WideString is in .NET? Would i have had to use the StringBuilder class?

Any comments or information would be great! Thanks
posted on Monday, January 7, 2008 5:48 PM