[DllImport("user32", EntryPoint="ShowCursor")]
解决方案 »
- 求解!使用guid类型后,objdatasource找不到id了!
- C#中如何调试父子进程之间的IPC通信呢?
- 请问获取与指定的值相关联的键
- Microsoft Visual C# 2010 Express 怎么新建 windows 服务程序
- 求服务器/客户机之间系统时间同步的对时程序源码!!!
- 如何得到当前机器剩余的物理内存数!
- 我在用(c#.net和ASP.NET)开发一个电子商务网站,当用户访问数超过最大数时,会出现什么问题,怎么解决???
- 关于调用本地的应用程序打开服务器上问题
- 请问怎样保存当前的论坛网页
- winform能不能显示url连接的图片
- 小弟刚学C#,遇到一点小问题!
- 请问各位朋友和高手有没有C#+DX9SDK的开发资料
{
using System;
// Must refernce this library to use PI nvoke types
using System.Runtime.InteropServices;
public class PinvokeClient
{
[DllImport("user32")]
public static extern int MessageBox(int hWnd,
String pText ,
String pCaption ,
int uType);
public static int Main(string[] args)
{
String pText = "HELLO INDIA!!";
String pCaption = "Example by Arungg";
MessageBox(0,pText,pCaption,0);
return 0;
}
}
}Explanation:Before calling a C-style Dll we have to declare the function to call using the static and extern C# keywords. After this you have to specify the name of the raw DLL that contain the function you are attempting to call,as shown here.[DllImport("user32")]
public static extern int MessageBox(.......);After declare the DLL Pass the arguments such as pText,pCaption.It should be clear that it does not matter in which order you specify the values.
In the above way one can use .Net types calling any type of raw C DLLs (Win32 API).This comes to an end of Part1 and I think the users now know how to call a raw C DLLs (Win32 API) using PInvoke in .NET.This is an end of Part1.