一定要加入引用:
using System.Runtime.InteropServices;
DllImport的用法:
DllImport("MyDllImport.dll")]
private static extern int mySum(int a,int b);
----------------------
一個例子:
Beep() 是在 kernel32.lib 中定義的,Beep具有以下原型:
BOOL Beep(DWORD dwFreq, DWORD dwDuration);
用C#編寫後的結果:
[DllImport("kernel32.dll")]
public static extern bool Beep(int frequency, int duration);


arrow
arrow
    全站熱搜

    神風地球喵 發表在 痞客邦 留言(1) 人氣()