vc怎么获取qq进程名字
#include <iostream.h>
#include <windows.h>
#include <commctrl.h>
char *_item;
char ConverNull(char s)
{
long nullpos;
nullpos= strlen(&s);
if (nullpos>0)
{
return s;
}
return 0;
}
void Qhq()
{
DWORD Pid1;
char strtext;
char strBuff[1024];
char lngTextAdr[1024];
char lngTextbuff[1024];
char lngText;
char lngTextId;
char strqq[1024];
HWND lngTem=FindWindow("Shell_TrayWnd",NULL);
lngTem=FindWindowEx(lngTem,NULL,"TrayNotifyWnd" ,NULL);
lngTem=FindWindowEx(lngTem,NULL,"SysPager",NULL);
HWND lngTray=FindWindowEx(lngTem,NULL,"ToolbarWindow32",NULL);
cout<<"------lngTray: "<< lngTray<<endl;
DWORD ret= GetWindowThreadProcessId(lngTray,&Pid1);
HANDLE hPrce= OpenProcess( PROCESS_ALL_ACCESS|PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE,
0,Pid1);
_item =(char*)VirtualAllocEx(hPrce, NULL, 512, MEM_COMMIT,
PAGE_READWRITE);
long lngButtons=SendMessage(lngTray, TB_BUTTONCOUNT, 0, 0);
for (int i=0;i<lngButtons-1;++i)
{ ret = SendMessage(lngTray, TB_GETBUTTON, i, (long) _item);
ret = ReadProcessMemory(hPrce, (PVOID) (_item + 16) , &lngTextAdr ,4,NULL );
}
if (lngTextAdr )
{
ret = ReadProcessMemory(hPrce, lngTextAdr , &strBuff ,1024,NULL );
ret = ReadProcessMemory(hPrce, (PVOID) (_item + 12) , &lngTextbuff ,4,NULL );
ret = ReadProcessMemory(hPrce, lngTextbuff , &lngText ,1024,NULL );
ret = ReadProcessMemory(hPrce, _item+4, &lngTextId ,4,NULL );
//写到此处下面不会了 这时防的一个vb程序
cout<<"------ret: "<< strBuff<<endl;
}
}
void main()
{
Qhq();
}
答案:原型:
int WINAPI icePub_getProcessInfo(char *strInfoList ,int maxLen)
输入:maxLen strInfoList最大长度
输出:strInfoList 进程基本信息,name|pid|path,一行一条信息
int recordCounts;
char buff[1024*30+1];
typedef int (WINAPI ICEPUB_GETPROCESSINFO)(char *strInfoList ,int maxLen);
ICEPUB_GETPROCESSINFO *icePub_getProcessInfo = 0;
HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
if(hDLLDrv)
{
icePub_getProcessInfo = (ICEPUB_GETPROCESSINFO *)GetProcAddress(hDLLDrv, "icePub_getProcessInfo");
}
if(icePub_getProcessInfo)
recordCounts=icePub_getProcessInfo(buff,1024*30);
if(hDLLDrv)
FreeLibrary(hDLLDrv);
AfxMessageBox(buff);
其他:HANDLE OpenProcess( DWORD dwDesiredAccess, // 访问标志 BOOL bInheritHandle, // 继承标志 DWORD dwProcessId // 进程ID ); 3.如何获取进程ID 进程ID 一般就是QQ.exe
上一个:vc++ 2010编译 2008项目问题
下一个:VC 6.0开发的软件用什么来做界面美化比较好?!