ví dụ 2 gọi dll từ ngôn ngữ bất kỳ PHP Code: using System; using System.Runtime.InteropServices; namespace AdvancedDotnet { class MainClass { ///Calc.dll chính là tên dll cần gọi ở đâ
Trang 1ví dụ 2
gọi dll từ ngôn ngữ bất kỳ
PHP Code:
using System;
using System.Runtime.InteropServices;
namespace AdvancedDotnet
{
class MainClass
{
///Calc.dll chính là tên dll cần gọi ở đây mình gọi dll calculator của window!
[DllImport("Calc.dll")]
///Khai báo lại hàm Add của calculator chú ý: hàm Add là hàm khai đã khai báo tron
g calculator
public static extern int Add(int var1,int var2);
public static void Main(string[] args)
{
int a = Add(15, 20);
Console.WriteLine("Result: {0}",a);
Console.Read();
}
}
}
_
dauden(UDS)