网站备案安全责任书是谁盖章,网站管理助手,贵州省建设网站,无线网网址是什么这里用c net 封装winapi函数
pch.h
// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次#xff0c;提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能#xff0c;包括代码完成和许多代码浏览功能。
// 但是#xff0c;如果此处列出的文件中的任何一个…这里用c net 封装winapi函数
pch.h
// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能包括代码完成和许多代码浏览功能。
// 但是如果此处列出的文件中的任何一个在生成之间有更新它们全部都将被重新编译。
// 请勿在此处添加要频繁更新的文件这将使得性能优势无效。#ifndef PCH_H
#define PCH_H// 添加要在此处预编译的标头
#include windows.h
#endif //PCH_HClassLibrary1.h
#pragma onceusing namespace System;namespace ClassLibrary1 {public ref class MYAPI{// TODO: 在此处为此类添加方法。public:int OpenProc(int pid);};
}ClassLibrary1.cpp
#include pch.h#include ClassLibrary1.hint ClassLibrary1::MYAPI::OpenProc(int pid)
{HANDLE hp OpenProcess(PROCESS_ALL_ACCESS, false, pid);int hproc (int)hp;return hproc;
}
这里用C# 调用 dll中的 winapi
把 dll 加入引用 只要 点击引用 添加 dll
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 ClassLibrary1;namespace WindowsFormsApp1
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){MYAPI mYAPI new MYAPI();int i mYAPI.OpenProc(11636);button1.Text i.ToString();}}
}
实例
https://download.csdn.net/download/nn_84/90115694?spm1001.2014.3001.5501