C # Use DllImport to call dephi dll
Generally, it is not hosted.
The specific format is as follows: [DllImport ("WZFSE. dll", CharSet = CharSet. Ansi, CallingConvention = CallingConvention. StdCall)]
The following is his declarative function.
Public static extern void InitDll (IntPtr handle, bool methodAddress );
Declare a function to reference its dll
IntPtr can be declared as a handle or pointer in other languages.
To implement a function pointer similar to C ++ in other languages, we should use the C # Delegate to implement
It is also important to check the dephi form into your C # system. We call the dephi form. The dephi form is displayed in the C # form.
In this case, what should we do? How can we remove the form in dephi? Now we need to use the API function, and the API function is also available in dephi C #.
In C #, [DllImport ("user32.dll", CharSet = CharSet. Ansi, CallingConvention = CallingConvention. StdCall)]
Public static extern void MoveWindow (IntPtr handler, int x, int y, int width, int height, bool repaint );
Insert a class below. Here, the package contains how to reference dephi dll and how to declare it.
Code 1 public class CompliancePlatDLL
2 {
3 public static string strPath = "";
4 /// <summary>
5 // Initialization
6 /// </summary>
7 // <param name = "handle"> </param>
8 /// <param name = "methodAddress"> </param>
9 [DllImport ("WZFSE. dll", CharSet = CharSet. Ansi, CallingConvention = CallingConvention. StdCall)]
10 public static extern void InitDll (IntPtr handle, bool methodAddress );
11 /// <summary>
12 // load the corresponding service
13 /// </summary>
14 /// <param name = "str"> </param>
15 /// <param name = "str2"> </param>