金玉妍是怎么被扳倒的:这个程序怎么得不到想要的结果?

来源:百度文库 编辑:中科新闻网 时间:2024/05/03 10:15:33
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lparam);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
wcout=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{

long lparam;
EnumWindows((WNDENUMPROC)EnumWindowsProc,lparam);
Label1->Caption ="总共有"+IntToStr(wcout)+"个进程";
Label2->Caption ="总共有"+IntToStr(ListBox2->Count)+"个进程";

}
//---------------------------------------------------------------------------

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lparam)
{
AnsiString str;
char *temp=new char[20];
char *tmp=new char[50];
GetWindowModuleFileName(hwnd,tmp,50);
Form1->ListBox2->Items->Add(String(tmp));
delete []tmp;
PTITLEBARINFO pti1;
int i=GetWindowText(hwnd,temp,20);
if(i)
{
if(i>=17)
{
temp[16]='.';
temp[17]='.';
temp[18]='.';
temp[19]='\0';
}
str=temp;
Form1->ListBox1->Items->Add(str);
Form1->wcout++;
delete []temp;

return true;

}
else
{

delete []temp;
// return false;

}
//TODO: Add your source code here
}
void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
ListBox2->Selected[ListBox1->ItemIndex]=true;
}
//---------------------------------------------------------------------------
谁说到了一点点:我这个程序是干嘛的
能说到一点就给他200分

我的水平还是太低

这个问题太复杂了你应该去找个专业的人去问一下

是passca 吗

是c++builder的程序吧,生成form一个由两个label一个button,click button显示顶层form的文字,找到文本框内所要寻找的进程

程序是一个枚举Windows下当前窗口的个数,并将枚举的的窗口的类名显示到ListBox2,将枚举的窗口的标题显示到ListBox1,如果标题长度大于17个字符,就将标题统一保存为18个字符.具体运行流程如下:
[按下安钮]-->[执行枚举Wind过程]-->[将枚举结果显示到Label]

说明一点,不是说有多少窗口就有多少进程,因为单个进程可以打开多个窗口,也可以没有一个窗口.

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lparam);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
wcout=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{

long lparam;
EnumWindows((WNDENUMPROC)EnumWindowsProc,lparam);
Label1->Caption ="总共有"+IntToStr(wcout)+"个进程";
Label2->Caption ="总共有"+IntToStr(ListBox2->Count)+"个进程";

}
//---------------------------------------------------------------------------

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lparam)
{
AnsiString str;
char *temp=new char[20];
char *tmp=new char[50];
GetWindowModuleFileName(hwnd,tmp,50);
Form1->ListBox2->Items->Add(String(tmp));
delete []tmp;
PTITLEBARINFO pti1;
int i=GetWindowText(hwnd,temp,20);
if(i)
{
if(i>=17)
{
temp[16]='.';
temp[17]='.';
temp[18]='.';
temp[19]='\0';
}
str=temp;
Form1->ListBox1->Items->Add(str);
Form1->wcout++;
delete []temp;

return true;

}
else
{

delete []temp;
// return false;

}
//TODO: Add your source code here
}
void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
ListBox2->Selected[ListBox1->ItemIndex]=true;
}
//---------------------------------------------------------------------------
问题补充:谁说到了一点点:我这个程序是干嘛的
能说到一点就给他200分