一聚教程网:一个值得你收藏的教程网站

热门教程

C#中与未操控语句交互运作

时间:2022-07-02 11:11:04 编辑:袖梨 来源:一聚教程网

using System;
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();

热门栏目