using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
[DllImport("user32.dll", EntryPoint="MessageBoxA")]
static extern int MsgBox(int hWnd, string msg, string caption, int type);
[DllImport("DmReg.dll", EntryPoint = "SetDllPathA")]
static extern int SetDllPathA(string path, int mode);
public void TestLateBind()
{
System.Type oType = System.Type.GetTypeFromProgID("dm.dmsoft");
object o = System.Activator.CreateInstance(oType);
object[] args = new object[] { code, mode };
object ret = oType.InvokeMember("reg", BindingFlags.InvokeMethod, null, o, args);
MsgBox(0, ret.ToString(), " 挑战杯 ", 0x30);
oType.InvokeMember("MoveTo", BindingFlags.InvokeMethod, null, o, new object[] { 0, 0 });
}
private void b1_Click(object sender, EventArgs e)
{
int res = 0;
res = SetDllPathA("dm.dll", 0);
TestLateBind();
}
}
}
C#面注册调用dm.dll
最新推荐文章于 2024-09-17 11:19:28 发布