注册 登录
编程论坛 C++教室

计算机病毒的问题

我爱你丁长青 发布于 2013-05-03 22:28, 779 次点击
请问一下高手用c++设计控制台程序怎么给它添加图标?2006年在网络中爆发的熊猫烧香病毒是用的是控制台还是控件?
6 回复
#2
天使梦魔2013-05-04 21:31
建立个控制台工程改图标就行了,代码写要打包资源,就目测你现在状态还是放弃吧。
#3
我爱你丁长青2013-05-04 21:56
回复 2楼 天使梦魔
您好老师您能给我看看这段代码吗?我不知道那里有错误?
#include<windows.h>
#include<stdio.h>

LRESULT CALLBACK WinSunProc(
  HWND hwnd,
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
);



int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
    WNDCLASS wndcls;
    wndcls.cbClsExtra=0;
    wndcls.cbWndExtra=0;
    wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
    wndcls.hCursor=LoadCursor(NULL.IDC.CROSS);
    wndcls.hInstance=hInstance;
    wndcls.lpfnWndproc=WinSunproc;
    wndcls.lpszClassNane="weixin2003";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW | cs_VREDRAW;
    RegisterClass(&wndcls);

    HWND hwnd;
    hwnd=CreateWindow("weixin2003","bei jing weixinkexue jishu pei xin zhongxin",WS_OVERLAPPEDWINDOW,
    0,0,600,400,NULL,hInstance,NULL);

    ShowWindow(hwnd,SW_SHOWNORMAL);
    UpdateWindow(hwnd);

    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
        translateMessage(&msg);
        DispatchMessage(&msg);

    }
    return 0;

}

LRESULT CALLBACK WinSunProc(
  HWND hwnd,
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
);
{
    switch(uMsg);
    {
    case WM_CHAR:
        char szChar[20];
        sprintf(szChar,"char is %d",wParam);
        MessageBox(hwnd,szChar,"weixin",0);
        break;
    case WM_LBUTTONDOWN:
        MessageBox(hwnd,"mouse clicked","weixin",0);
        HDC hdc;
        hdc=GetDC(hwnd);
        TextOut(hdc,0,50,"ji suan ji yu yan pei xun",strlen("ji suan ji yu yan pei xun"));
        REleaseDC(hwnd,hdc);

        break;
    case WM_PAINT:
        HDC hDC;
        PAINTSTRUCT ps;
        hDC=BeginPaint(hwnd,&ps);
        TextOut(hDC,0,0,"wei xin pei xun",strlen("wei xin pei xun"));
        EndPaint(hwnd,&ps);
        break;
    case WM_CLOSE:
        if(IDYES==MessageBox(hwnd,"shi fou zhen de jie shu?","weixin",MB_YESNO))
        {
            Destroywindow(hwnd);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd,uMsg,wParam,lParam);


    }
    return 0;

}
#4
wp2319572013-05-05 09:22
这是控制台程序吗
#5
yuccn2013-05-05 10:02
你是指写改pe文件的图标还是说你自己的工程的图标?如果修改pe的,修改对应的资源就行了
#6
我爱你丁长青2013-05-08 19:50
回复 5楼 yuccn
具体操作是什么还请高手多多指教
#7
我爱你丁长青2013-06-14 22:37
回复 5楼 yuccn
我想像蠕虫病毒一样感染全部图标该怎么做?
1