首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

小弟我从网上看到的代码,小弟我修改成了精简版!可是有一个异常解决不了

2012-05-05 
我从网上看到的代码,我修改成了精简版!可是有一个错误解决不了!#includetlhelp32.h#includewindows.h#

我从网上看到的代码,我修改成了精简版!可是有一个错误解决不了!
#include<tlhelp32.h>
#include<windows.h>
#include <time.h>

HINSTANCE hInst;?
HWND hWnd;

/************** 程序ID定义 ******************/?
?
#define id_Send 0x77E //发送按扭的ID?
#define id_SendQQMsg 1001 //控制发送QQ消息的定时器ID?

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)?
{?
HWND hFore, hChat, hParent; ?
?
char szTest[] = "这是我的QQ主页哦! http://user.qzone.qq.com/406960655 \";?
HWND hWnd=NULL;?
char name[200];?
int len;?
char ch[3] = {0, 0, 0};?
while(hWnd=FindWindowEx(NULL,hWnd,NULL,NULL))?
{?
GetWindowText(hWnd,name,200);?
len=strlen(name);?
ch[0]=name[len-2];?
ch[1]=name[len-1];?

if(strcmp(ch,"群\")==0 || strcmp(ch,"中\")==0 )?
{?
hFore=FindWindow(NULL,name); ?
?
hParent=FindWindowEx(hFore,NULL,"#32770\",NULL); ?
hChat=FindWindowEx(hParent,NULL,"AfxWnd42\",NULL); ?
hChat=FindWindowEx(hParent,hChat,"AfxWnd42\",NULL); ?
hChat=FindWindowEx(hChat,NULL,"RichEdit20A\",NULL); ?
if( hChat )?
{?
SendMessage( hChat ,EM_REPLACESEL,0,LPARAM(szTest));?
SendMessage(hParent,WM_COMMAND,id_Send,BN_CLICKED);?
}?
}?
}?
}
vc6编译错误:
Compiling...
初级cpp.cpp
d:\常用软件\vc6.0_完整绿色版\vc98\include\tlhelp32.h(26) : error C2146: syntax error : missing ';' before identifier 'WINAPI'
d:\常用软件\vc6.0_完整绿色版\vc98\include\tlhelp32.h(26) : error C2501: 'HANDLE' : missing storage-class or type specifiers
d:\常用软件\vc6.0_完整绿色版\vc98\include\tlhelp32.h(26) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

初级cpp.obj - 1 error(s), 0 warning(s)
求解决办法!

[解决办法]

C/C++ code
#include "stdafx.h"#include<windows.h>#include<tlhelp32.h>#include <time.h>HINSTANCE hInst;  HWND hWnd;/************** 程序ID定义 ******************/  #define id_Send 0x77E //发送按扭的ID  #define id_SendQQMsg 1001 //控制发送QQ消息的定时器ID  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)  {      HWND hFore, hChat, hParent;           char szTest[] = "这是我的QQ主页哦! http://user.qzone.qq.com/406960655";      HWND hWnd=NULL;      char name[200];      int len;      char ch[3] = {0, 0, 0};      while(hWnd=FindWindowEx(NULL,hWnd,NULL,NULL))      {          GetWindowText(hWnd,name,200);          len=strlen(name);          ch[0]=name[len-2];          ch[1]=name[len-1];                  if(strcmp(ch,"群")==0 || strcmp(ch,"中")==0 )          {              hFore=FindWindow(NULL,name);                           hParent=FindWindowEx(hFore,NULL,"#32770",NULL);                   hChat=FindWindowEx(hParent,NULL,"AfxWnd42",NULL);                   hChat=FindWindowEx(hParent,hChat,"AfxWnd42",NULL);                   hChat=FindWindowEx(hChat,NULL,"RichEdit20A",NULL);                   if( hChat )                  {                      SendMessage( hChat ,EM_REPLACESEL,0,LPARAM(szTest));                      SendMessage(hParent,WM_COMMAND,id_Send,BN_CLICKED);                  }          }      }      return 0;}
[解决办法]
把引号中的字符串最后一个‘\’去掉

热点排行