For example if I'm working on Visual Studio 2008, I want the values devenv and 2008 or 9.
例如,如果我正在使用Visual Studio 2008,我想要值devenv和2008或9。
The version number is very important...
版本号非常重要......
3 个解决方案
#1
8
This is going to be PInvoke city...
这将是PInvoke市......
You'll need to PInvoke the following API's in User32.dll
您需要在User32.dll中PInvoke以下API
Win32::GetForegroundWindow() in returns the HWND of the currently active window.
Win32 :: GetForegroundWindow()返回当前活动窗口的HWND。
/// <summary>
/// The GetForegroundWindow function returns a handle to the foreground window.
/// </summary>
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
Win32::GetWindowThreadProcessId(HWND,LPDWORD) returns the PID of a given HWND
Win32 :: GetWindowThreadProcessId(HWND,LPDWORD)返回给定HWND的PID
[DllImport("user32.dll", SetLastError=true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
In C#
Process.GetProcessByID() takes the PID to create a C# process object
Process.GetProcessByID()获取PID以创建C#进程对象
processInstance.MainModule returns a ProcessModule with FileVersionInfo attached.
processInstance.MainModule返回附加了FileVersionInfo的ProcessModule。
#2
0
This project demonstrates the two functions you need: EnumWindows and GetWindowtext
该项目演示了您需要的两个函数:EnumWindows和GetWindowtext
#3
0
Can you clarify your question? Do you mean you want a program running, which will tell you data about the program in the active window? Or that you want your program to report out its own version?
你能澄清一下你的问题吗?你的意思是你想要一个程序运行,它将告诉你活动窗口中有关该程序的数据?或者您希望程序报告自己的版本?
What you're looking for to get the information either way is System.Reflection.Assembly. (See code examples in the link.)
您要查找的信息是System.Reflection.Assembly。 (请参阅链接中的代码示例。)
How to get the assembly from an external program? That one I'm not sure about...
如何从外部程序获取程序集?那个我不确定...
#1
8
This is going to be PInvoke city...
这将是PInvoke市......
You'll need to PInvoke the following API's in User32.dll
您需要在User32.dll中PInvoke以下API
Win32::GetForegroundWindow() in returns the HWND of the currently active window.
Win32 :: GetForegroundWindow()返回当前活动窗口的HWND。
/// <summary>
/// The GetForegroundWindow function returns a handle to the foreground window.
/// </summary>
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
Win32::GetWindowThreadProcessId(HWND,LPDWORD) returns the PID of a given HWND
Win32 :: GetWindowThreadProcessId(HWND,LPDWORD)返回给定HWND的PID
[DllImport("user32.dll", SetLastError=true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
In C#
Process.GetProcessByID() takes the PID to create a C# process object
Process.GetProcessByID()获取PID以创建C#进程对象
processInstance.MainModule returns a ProcessModule with FileVersionInfo attached.
processInstance.MainModule返回附加了FileVersionInfo的ProcessModule。
#2
0
This project demonstrates the two functions you need: EnumWindows and GetWindowtext
该项目演示了您需要的两个函数:EnumWindows和GetWindowtext
#3
0
Can you clarify your question? Do you mean you want a program running, which will tell you data about the program in the active window? Or that you want your program to report out its own version?
你能澄清一下你的问题吗?你的意思是你想要一个程序运行,它将告诉你活动窗口中有关该程序的数据?或者您希望程序报告自己的版本?
What you're looking for to get the information either way is System.Reflection.Assembly. (See code examples in the link.)
您要查找的信息是System.Reflection.Assembly。 (请参阅链接中的代码示例。)
How to get the assembly from an external program? That one I'm not sure about...
如何从外部程序获取程序集?那个我不确定...