Lessons XII : Code Example – ví dụ 2

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 ở đâ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 trong 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)

 

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: