0

Are there any best practices to call native C++ or Delphi Dlls from C# (ASP.NET)? Is invoking or a COM interop the best way to access those Dlls?

codekaizen
  • 26,990
  • 7
  • 84
  • 140
Konrad
  • 4,329
  • 10
  • 54
  • 88

1 Answers1

1

You can use DllImport to achieve your objective, as per the following:

[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);

You can use this with any Win32 compatible DLL, including Delphi ones.

Martin
  • 16,093
  • 1
  • 29
  • 48
  • Does this also works on 64bit machines calling 32bit DLLs? Or do I have to provide the 64bit DLLs of the native code for those cases? – Konrad Mar 14 '13 at 14:00
  • 2
    @Konrad If you build your C# code as x86 then you provide 32-bit DLL. If you build as "AnyCPU" you need to provide 32-bit DLL on x86 OS, and 64-bit DLL on x64 OS. – Alvin Wong Mar 14 '13 at 14:02