1.引用名称空间。
using System.Runtime.InteropServices;
2.函数申明。
以接口:
UINT mciSendString(LPCTSTR lpszCommand, LPTSTR lpszReturnString, UINT cchReturn, HANDLE hwndCallback);
c#声明如下:
[DllImport("winmm.dll")]
public static extern int mciSendString(string cmd, string msg, int msgSize, int hwnd);
3.调用。
mciSendString(string.Format("open {0}", fullName)
,null, 0, 0
);
本文介绍如何使用C#通过P/Invoke调用Win32 API函数mciSendString,实现多媒体控制接口的功能。具体步骤包括:1) 引用System.Runtime.InteropServices名称空间;2) 声明DllImport属性的mciSendString函数;3) 调用该函数打开指定的多媒体文件。
6673

被折叠的 条评论
为什么被折叠?



