public void game()
{
int proID,proid1;
proID = OpenProcess("PROCESS_VM_READ", false, Phandle);//它返回的是什么,我得到的总是0?
//textBox2.Text = proID.ToString();
proid1 = GetWindowThreadProcessId(Phandle,null);//它有返回值,可的返回的是进程ID,还是线程ID,或是哪个的句柄??
//textBox3.Text = proid1.ToString();
} private void timer1_Tick(object sender, EventArgs e)
{
Phandle = FindWindow("SciCalc", null);
if (Phandle != 0)
{
label1.Text = "计算器运行!";
game();
textBox1.Text = Phandle.ToString();
}
else
{
label1.Text = "计算器未运行!";
}
}
{
int proID,proid1;
proID = OpenProcess("PROCESS_VM_READ", false, Phandle);//它返回的是什么,我得到的总是0?
//textBox2.Text = proID.ToString();
proid1 = GetWindowThreadProcessId(Phandle,null);//它有返回值,可的返回的是进程ID,还是线程ID,或是哪个的句柄??
//textBox3.Text = proid1.ToString();
} private void timer1_Tick(object sender, EventArgs e)
{
Phandle = FindWindow("SciCalc", null);
if (Phandle != 0)
{
label1.Text = "计算器运行!";
game();
textBox1.Text = Phandle.ToString();
}
else
{
label1.Text = "计算器未运行!";
}
}
解决方案 »
- 高分求:winform 如何获取用户的FTP文件列表?并绑定到treeview
- 静态方法只能访问类的静态成员,不能访问类的非静态成员;哪们高手从原理上能解释下
- webservice 客户端发现响应内容类型为“text/html; charset=utf-8”,但应为“text/xml”。
- c#画线问题
- 关于WebForm中异步程序的问题。
- 怎么查看guest账户状态
- 100分求System.DirectoryServices.DirectoryEntry创建站点的相关方法
- 高手请进:MSDE同应用程序的安装部署(在线等待)
- 在richTextBox中,当用户按下一个按键,我如何才能知道当前光标在第几行、第几列?
- 用owc可以设置页面为横向打印吗?
- 请教cookie更新滞后问题
- c#连接两个数据库100分
不是文本 ,有关是数值常量啊
现在的人们要求越来越高!事情还是十画还没有一撇,就要源码!
proid1 = GetWindowThreadProcessId(Phandle,null);//它有返回值,可的返回的是进程ID,还是线程ID,或是哪个的句柄??这两个返回的是什么值??
OpenProcess成功的话返回process的句柄,否则返回null
GetWindowThreadProcessId返回的是线程ID,第二个参数是接收进程ID的
MSDN上都有
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
[DllImport("User32.dll")]
public static extern int FindWindow(string s,string ss); [DllImport("Kernel32.dll")]
public static extern int OpenProcess(int dwDesiredAccess, bool bInheritHandle,int dwProcessId); [DllImport("user32.dll")]
public static extern int GetWindowThreadProcessId(int hWnd,string lpdwProcessId); public void game()
{
const int PROCESS_VM_READ = 16;
int proID,proid1;
proID = OpenProcess(16, false, Phandle);//这样不对吗,返回还是0
textBox2.Text = proID.ToString();
proid1 = GetWindowThreadProcessId(Phandle,null);
textBox3.Text = proid1.ToString();
} public Form1()
{
InitializeComponent();
} int Phandle;
private void button1_Click(object sender, EventArgs e)
{
} private void Form1_Load(object sender, EventArgs e)
{
} private void timer1_Tick(object sender, EventArgs e)
{
Phandle = FindWindow("SciCalc", null);
if (Phandle != 0)
{
label1.Text = "计算器运行!";
game();
textBox1.Text = Phandle.ToString();
}
else
{
label1.Text = "计算器未运行!";
}
} private void textBox1_TextChanged(object sender, EventArgs e)
{ }
}
}接触时间不常,问一下,private void textBox1_TextChanged(object sender, EventArgs e)像这样,我不用的,要怎么把它删掉?
private static extern int GetWindowThreadProcessId(int hWnd, ref int ProcessId);int pid = 0;
GetWindowThreadProcessId(Phandle, ref pid);//ProcessID存入pid
int hProcess = OpenProcess(PROCESS_VM_READ, false, pid);private void textBox1_TextChanged(object sender, EventArgs e)之类的你可以在属性窗口里的事件里面删除
不点不明白
EntryPoint = "GetWindowThreadProcessId为什么要加这个,我试了,不写也可以啊?