我爱Aspx >> Asp.Net >> 在C#里如何调用标准DLL函数在C#里只需要调用PInvoke (Platform Invocation) 服务。C# 支持一种sysimport属性
支持这种调用。
下面是完整的语法形式(在例子里没有用到所有的参数):
[sysimport(
dll=dllName,
name=functionName,
charset=characterSetToBeUsed)
]
给出一个调用Win32 MessageBox函数的例子:
using System;
class pinvokeClient
{
[sysimport(dll="user32.dll")]
public static extern int MessageBoxA(int hwnd, string message,
string caption, int type);
public static void Main()
{
int result = MessageBoxA(0, "Hello World", "PInvoke Test", 0);
}
}
C#抢鲜快报之FAQ20[05-05]
Beginner with c# 7[05-05]
Beginner with c# 6[05-05]
Beginner with c# 5[05-05]
Beginner with c# 4[05-05]
Beginner with c# 3[05-05]
Beginner with c# 2[05-05]
Beginner with C#[05-05]
C#技术内幕 学习笔记[05-05]
Autodesk官方最新的.NET教程(一..[05-05]
开放源代码的定义[05-05]
MMX Instructions[05-05]
Opcodes of intel[05-05]
程序员与MM[05-05]
用CTI实现与Web交谈[05-05]
CTI技术和呼叫中心[05-05]
CTI的典型应用之三[05-05]
CTI的典型应用之二[05-05]
CTI的典型应用之一[05-05]
了解CTI[05-05]