如何在C#中调用Windows API

jiangfeng999 2004-08-28 11:05:47
我用VS.net 2003中调用windows api,可编译器却认不到“sysimport”,代码如下:
using System;
class HelloWorld
{
[sysimport(dll = "user32.dll")]
public static extern int MessageBoxA(int h, string m,
string c, int type);

public static int Main()
{
return MessageBoxA(0, "Hello World!", "Caption", 0);
}
}
在这儿向各位请教一下
...全文
188 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
czsd82 2004-09-05
  • 打赏
  • 举报
回复
坚决收藏
ilqtj 2004-08-29
  • 打赏
  • 举报
回复
using System.Runtime.InteropServices;
[DllImport("User32.dll",EntryPoint="SendMessage")]
    private static extern int SendMessage(
          int hWnd,
          int Msg,
          int wParam,
          int lParam);
benbencatrabbit 2004-08-29
  • 打赏
  • 举报
回复
xue xi
diaoerlangdang 2004-08-29
  • 打赏
  • 举报
回复
推荐的网站确实不错,俺也收藏
The123 2004-08-29
  • 打赏
  • 举报
回复
楼上给的网站不错,收藏,:)
zhpsam109 2004-08-29
  • 打赏
  • 举报
回复
http://custom.programming-in.net/articles/art9-1.asp?f=CreatePipe

同时推荐网站:http://custom.programming-in.net
yangkang0752 2004-08-29
  • 打赏
  • 举报
回复
using System.Runtime.InteropServices;
The123 2004-08-28
  • 打赏
  • 举报
回复
using SYstem.Interopservice
SORRY 更正:
using System.Runtime.InteropServices;
lxhvc 2004-08-28
  • 打赏
  • 举报
回复
同意 The123(在我地盤這 伱就得聽我的)的意见
zhpsam109 2004-08-28
  • 打赏
  • 举报
回复

!
winxieddd 2004-08-28
  • 打赏
  • 举报
回复
using System;
using System.Runtime.InteropServices;
class MainApp
{ //通过DllImport引用user32.dll类。MessageBox来自于user32.dll类
 [DllImport("user32.dll", EntryPoint="MessageBox")]
 public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);
 public static void Main()
 {
  MessageBox( 0, "hello", ".NET", 0 );
 }
}
The123 2004-08-28
  • 打赏
  • 举报
回复
using SYstem.Interopservice

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧