小弟我只知道,进程的映像名称,如何通过,进程的映像名称,来激活一个这个进程并获得程序主窗口句柄,让这个主窗口置顶,置顶后获取当前窗口
我只知道,进程的映像名称,怎么通过,进程的映像名称,来激活一个这个进程并获得程序主窗口句柄,让这个主窗口置顶,置顶后获取当前窗口
我只知道,进程的映像名称,怎么通过,进程的映像名称,来激活一个这个进程并获得程序主窗口句柄,让这个主窗口置顶,置顶后获取当前窗口句柄?
------解决方案--------------------
根据映像名很容易可知道进程ID,下面是如何根据进程ID获取主窗口:
http://tech.ddvip.com/2006-04/11444325604256.html
获得主窗口后发送消息就可以了.
------解决方案--------------------
根据以下代码,找到processname然后可以得到对应的processid.
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include "psapi.h "
void PrintProcessNameAndID( DWORD processID )
{
TCHAR szProcessName[MAX_PATH] = TEXT( " <unknown> ");
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName)/sizeof(TCHAR) );
}
}
// Print the process name and identifier.
_tprintf( TEXT( "%s (PID: %u)\n "), szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
// Get the list of process identifiers.
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
}
我只知道,进程的映像名称,怎么通过,进程的映像名称,来激活一个这个进程并获得程序主窗口句柄,让这个主窗口置顶,置顶后获取当前窗口句柄?
------解决方案--------------------
根据映像名很容易可知道进程ID,下面是如何根据进程ID获取主窗口:
http://tech.ddvip.com/2006-04/11444325604256.html
获得主窗口后发送消息就可以了.
------解决方案--------------------
根据以下代码,找到processname然后可以得到对应的processid.
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include "psapi.h "
void PrintProcessNameAndID( DWORD processID )
{
TCHAR szProcessName[MAX_PATH] = TEXT( " <unknown> ");
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName)/sizeof(TCHAR) );
}
}
// Print the process name and identifier.
_tprintf( TEXT( "%s (PID: %u)\n "), szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
// Get the list of process identifiers.
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
}