在C#中如何调用WindowsAPI函数?

guolianghu 2003-08-19 12:08:34
在C#中如何调用WindowsAPI函数,请赐教一个实例,谢谢!
...全文
55 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dotnba 2003-08-24
  • 打赏
  • 举报
回复
看看:
<Root>\SDK\v1.1\Samples\Technologies\Interop\PlatformInvoke
panyee 2003-08-19
  • 打赏
  • 举报
回复
C#怎样打开关闭CDROM?
using System;
using System.Text;
using System.Runtime.InteropServices;

class CloseCD
{

[DllImport("winmm.dll", EntryPoint="mciSendStringA", CharSet=CharSet.Ansi )]
protected static extern int mciSendString( string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, IntPtr hwndCallback );

public static void Main()
{

int ret = mciSendString( "set cdaudio door open", null, 0, IntPtr.Zero );

Console.ReadLine();

ret = mciSendString( "set cdaudio door closed", null, 0, IntPtr.Zero );
}
}
popcorn 2003-08-19
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=6956
popcorn 2003-08-19
  • 打赏
  • 举报
回复
[DllImport("rasapi32.dll")]
public static extern int RasGetEntryDialParams(string pbook,IntPtr ipBuff,bool b);


/// <summary>
/// 枚举窗口
/// </summary>
[DllImport("user32.Dll")]
public static extern int EnumWindows(CallBack x, int y);

/// <summary>
/// 取窗口标题
/// </summary>
[DllImport("User32.Dll")]
public static extern void GetWindowText(IntPtr h, StringBuilder s, int nMaxCount);

110,499

社区成员

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

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

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