除了用Console模式,怎么才能创建一个没有Form的程序,而且体积要小的那种?

bcboy 2003-09-03 10:11:09
就像一些后门程序一样,文件很小,但功能强大.
...全文
25 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
gloom 2003-09-03
  • 打赏
  • 举报
回复
1.New->Appliaction
2.Project->Remove From Project->Unit1
3.Project->View Source在此写代码
4.Builder后用Aspack压缩一下
netsys2 2003-09-03
  • 打赏
  • 举报
回复
记得把分给NowCan

回复人: NowCan(能量、激情、雨水、彩虹——雷雨云) ( ) 信誉:110 2003-01-22 17:19:00 得分:0


shak,不要#include <vcl.h>!
看看这个程序。
#include <windows.h>

const int Nx=300;
const int Ny=200;
const int Max=300;
const int Scale=3;
const int CoolRate=20;
const int FuleQuality=5;

int clr[2][Nx][Ny];
int base[Nx];
int sel=0;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

/* */

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[]="Application";
MSG msg;
WNDCLASS wndclass;
HWND hWnd;

wndclass.style=CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(hInstance, "MainIcon");
wndclass.hCursor=LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground=(HBRUSH) GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName="mnuMain";
wndclass.lpszClassName=szAppName;

RegisterClass(&wndclass);

hWnd=CreateWindow(szAppName, "<Alt>+<F4> to exit.", WS_OVERLAPPED, 0, 0, 900, 630, NULL, NULL, hInstance, NULL);

ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
SetTimer(hWnd, 1, 75, 0);

while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return msg.wParam;
}

/* */
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int i, j;
int x, y;
PAINTSTRUCT ps;
HDC hdc;
BITMAPINFO bmpinf;
void *vptr;
static DWORD *sptr;
static HDC shdc;
static HBITMAP shbmp;

switch(message)
{
case WM_CREATE:
// Initialize bitmap infomation
bmpinf.bmiHeader.biSize=sizeof(bmpinf.bmiHeader);
bmpinf.bmiHeader.biPlanes=1;
bmpinf.bmiHeader.biBitCount=32;
bmpinf.bmiHeader.biCompression=BI_RGB;
bmpinf.bmiHeader.biSizeImage=0;
bmpinf.bmiHeader.biClrUsed=0;
bmpinf.bmiHeader.biClrImportant=0;

bmpinf.bmiHeader.biWidth=Nx * Scale;
bmpinf.bmiHeader.biHeight=Ny * Scale;
shdc=CreateCompatibleDC(NULL);
shbmp=CreateDIBSection(NULL, &bmpinf, DIB_RGB_COLORS, &vptr, NULL, 0);
SelectObject(shdc, shbmp);
sptr= (DWORD *)vptr;

srand(GetTickCount());

// Initialize the color array.
for(i=0; i < Nx; i++)
for(j=0; j < Ny; j++)
{
clr[0][i][j]=clr[1][i][j]=0;
}

// Initialize the base color array.
for(i=0; i < Nx; i++) base[i]=rand() * Max / RAND_MAX;
return 0;

case WM_TIMER:
// Calculate
for(i=0; i < Nx; i++)
{
clr[sel][i][0]=base[i];
}

for(i=0; i < Nx; i++)
for(j=0; j < Ny; j++)
{
clr[!sel][i][j]=0;
}

for(i=0; i < Nx; i++)
{
for(j=0; j < Ny; j++)
{
int temp=clr[sel][i][j];
int grow=temp / 80;
for(x=i - grow; x <= i + grow; x++)
{
for(y=j + 2 * grow; y <= j + 4 * grow; y++)
{
if(x >= 0 && x < Nx && y >= 0 && y < Ny)
{
clr[!sel][x][y]+=clr[sel][i][j] / (4 * grow * grow + 4 * grow + 1) + FuleQuality;
if(clr[!sel][x][y] > Max) clr[!sel][x][y]=Max;
}
}
}
}
}

for(i=0; i < Nx; i++)
for(j=0; j < Ny; j++)
{
if(clr[!sel][i][j] >= CoolRate) clr[!sel][i][j]-=CoolRate;
}

sel=!sel;

// Display
for(i=0; i < Nx; i++)
{
for(j=0; j < Ny; j++)
{
int temp=clr[sel][i][j];
int cref;

// Calculate the color to display on the screen.
if(temp < Max / 3)
cref=(temp * 255 * 3 / Max) << 16;
else if(temp < Max * 2 / 3)
cref=(255 << 16) + ((temp * 255 * 3 / Max - 255) << 8);
else
cref=(255 << 16) + (255 << 8) + (temp * 255 * 3 / Max - 2 * 255);
for(x=0; x < Scale; x++)
{
for(y=0; y < Scale; y++)
{
DWORD *p=sptr + (Scale * i + x) + (Scale * j + y) * Scale * Nx;
*p=cref;
}
}
}
}

InvalidateRgn(hwnd, 0, FALSE);
return 0;

case WM_PAINT:
hdc=BeginPaint(hwnd, &ps);
BitBlt(hdc, 0, 0, Nx * Scale, Ny * Scale, shdc, 0, 0, SRCCOPY);
EndPaint(hwnd, &ps);
return 0;

case WM_LBUTTONDBLCLK:
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}

return DefWindowProc(hwnd, message, wParam, lParam);
}




Top

回复人: NowCan(能量、激情、雨水、彩虹——雷雨云) ( ) 信誉:110 2003-01-22 17:23:00 得分:0


保存为 f.cpp,然后命令行
bcc32 -W f

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧