C#中与未操控语句交互运作
using System.Runtime.InteropServices;
namespace FastCSharp
{
class Class1
{
[STAThread]
unsafe static void Main(string[] args)
{
// comInvoke();
// helloWorld();
// StructInvoke();
// classInvode();
// PointerInvoke();
unsafeMethod();
}
// 调用一个com组件
// tlbimp工具
public static void comInvoke()
{
//string fileName = "c:windowsclock.avi";
string fileName = @"C:Documents and SettingsAdministrator桌面WebApplication1心中心密咒dgmz.wma";
QuartzTypeLib.FilgraphManager graphManager = new QuartzTypeLib.FilgraphManagerClass();
QuartzTypeLib.IMediaControl mc = (QuartzTypeLib.IMediaControl)graphManager;
mc.RenderFile(fileName);
mc.Run();
Console.WriteLine("Hello World");
Console.ReadLine();
}
public static void helloWorld()
{
Win32Invoke.MessageBox(0,"Hello World","Platform Invoke Sample",0);
}
// 传递结构变量
public static void StructInvoke()
{
Point p = new Point();
p.x = 1;
p.y = 1;
Rect r = new Rect();
r.left = 0;
r.bottom = 2;
r.right = 2;
r.top = 0;
bool b = Win32Invoke.PtInRect(ref r,p);
System.Console.WriteLine("Point[1,1] is int Rect[0,0,2,2] ?" b );
}
// 传递一个对象
public static void classInvode()
{
MySystemTime t = new MySystemTime();
您可能感兴趣的文章:
C#中与未操控语句交互运作
inux shell初级入门教程
PHP的作用是什么?
数据库查询语言(1)
python和c语言的区别是什么
c# lock详细介绍与实现
PHP面试踩过的坑
C#就是Java只不过差了一点点
Python 基础语法
C#中GridView控件与数据库交互的方法详解