asp.net中怎么样调用外部dll?(50分)

D

dearwo

Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个delphi开发的dll,里面有我需要的函数,我想在我的web 应用程序中调用它里面的函数,请问怎么用?
 
用托管!如:
public class Win32API
{
[ DllImport( "Kernel32.dll" )]
public static extern bool SetSystemTime([In,
MarshalAs(UnmanagedType.LPStruct)]SYSTEMTIME lpSystemTime);
}
 
我刚学asp.net ,什么叫托管,请多多指教
能不能详细点
 
以下示例将说明如何定义和调用 User32.dll 中的 MessageBox 函数,并将简单字符串当作参数进行传递。在这些示例中,CharSet 对象字段设置为 Auto,以便让目标平台确定字符宽度和字符串封送处理。

[Visual Basic]
Imports System.Runtime.InteropServices
Public Class Win32
Declare Auto Function MessageBox Lib "user32.dll"(hWnd As Integer, _
txt As String, caption As String, Typ As Integer) As Integer
End Class
Public Class HelloWorld
Public Shared Sub Main()
Win32.MessageBox(0, "Hello World", "Platform Invoke Sample", 0)
End Sub
End Class
[C#]
using System.Runtime.InteropServices;
public class Win32 {
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MessageBox(int hWnd, String text,
String caption, uint type);
}
public class HelloWorld {
public static void Main() {
Win32.MessageBox(0, "Hello World", "Platform Invoke Sample", 0);
}
}
 
顶部