■■■看看我用Delhpi写的仅有13KB的程序■■■

goomoo 2003-09-05 12:29:28
看看我用Delphi写的仅有13KB的程序,呵呵~~

下载地址:
http://www.goomoo.net/tmp/fallwin.exe

注意:按 Esc 键退出。
...全文
29 42 打赏 收藏 转发到动态 举报
写回复
用AI写文章
42 条回复
切换为时间正序
请发表友善的回复…
发表回复
goomoo 2003-09-08
  • 打赏
  • 举报
回复
//源代码

program fallWin;

uses
windows, messages;

{$R *.res}

type
TWindowInfo = record
Handle: THandle;
Caption: String;
Rect: TRect;
Speed: Byte;
end;


const
gDebug = False;
var
windowsInfoList: array of TWindowInfo;
gAtom: ATOM;
winCount, aInt, gScreenHeight, gScreenWidth, gIndex: Integer;
msg: tagMsg;
threadIdList: array of DWORD;
//speedFactor:UINT;

procedure debugMsg(s: String);
begin
if gDebug then
messageBox(0, PChar(s), 'Debug Message', 0);
end;

function enumWindowsProc(_hwnd: HWND; _lparam: LPARAM): BOOL; stdcall;
var
Caption: array[0..511] of Char;
rect: TRect;
_length: Integer;
begin
Result := True;

if _hwnd = HWND_DESKTOP then
exit;
if not isWindowVisible(_hwnd) then
exit;

getWindowText(_hwnd, Caption, 512);
if (String(Caption) = '') or (String(Caption) = 'Program Manager') then
exit;

//debugMsg(string(caption));

getWindowRect(_hwnd, rect);

if ((rect.Bottom - rect.Top) = gScreenHeight) then
exit;

if isIconic(_hwnd) then
exit; //showWindow(_hwnd,SW_RESTORE);

setLength(windowsInfoList, length(windowsINfoList) + 1);
_length := length(windowsInfoList) - 1;
windowsInfoList[_length].Handle := _hwnd;
windowsInfoList[_length].Rect := rect;
windowsInfoList[_length].Caption := String(Caption);
windowsInfoList[_length].Speed := random(127) + 1;
end;

procedure restoreWindows;
var
i: Integer;
_hwnd: HWND;
x, y: Integer;
begin
for i := 0 to winCount - 1 do
begin
_hwnd := windowsInfoList[i].Handle;
x := windowsInfoList[i].Rect.Left;
y := windowsInfoList[i].Rect.Top;
setWindowPos(_hwnd, 0, x, y, 0, 0, SWP_NOZORDER or SWP_NOSIZE);
end;
end;

procedure getWindowsInfo;
begin
enumWindows(@enumWindowsProc, 0);
end;

function threadProc(lpdData: LPDWORD): DWORD; stdcall;
var
x, y, sn: Integer;
rect: TRect;
begin
inc(gIndex);
sn := gIndex;
//debugMsg(intToStr(gIndex));
while (True) do
begin
getWindowRect(windowsInfoList[sn].Handle, rect);
x := Rect.Left;
y := Rect.Top;
y := y + windowsInfoList[sn].Speed;

if y > gScreenheight then
begin
y := -gScreenHeight;
x := random(gScreenWidth);
end;

setWindowPos(windowsInfoList[sn].Handle, 0, x, y, 0, 0,
SWP_NOSIZE or SWP_NOZORDER);

sleep(32);
end;

Result := 1;
end;


//////////////////////////////////////////////////////////////////////////////
// start from here ///////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////


begin

gAtom := globalFindAtom('fallWindowsScreen');
if gAtom <> 0 then // program have a previous instance
begin
//globalDeleteAtom(gAtom);
exit;
end;

// get screen's height
gScreenWidth := getSystemMetrics(SM_CXFULLSCREEN);
gScreenHeight := getSystemMetrics(SM_CYFULLSCREEN);

//register hotkey
gAtom := globalAddAtom('fallWindowsScreen');
registerHotKey(0, gAtom, 0, VK_ESCAPE); // press ESC to exit

getWindowsInfo;

winCount := length(windowsInfoList);
//debugMsg(intToStr(winCount));

setLength(threadIdList, winCount);

for aInt := 0 to winCount - 1 do
begin
//create threads for every window
createThread(nil, 0, @threadProc, nil, 0, threadIdList[aInt]);
//setTimer(0,0,160,@timerProc);
end;

// message loop
while (getMessage(msg, 0, 0, 0)) do
begin
if msg.message = WM_HOTKEY then
begin
globalDeleteAtom(gAtom);
restoreWindows;
//MessageBox(0,'Please visit http://www.goomoo.net to get more goodies! ;-)','Information',0);
exit;
end
else
begin
translateMessage(msg);
dispatchMessage(msg);
end;
end;
end.
reallike 2003-09-08
  • 打赏
  • 举报
回复
无聊啊,小有何用?大有何用?我都不知道大小到底有什么用…
mrtxc 2003-09-08
  • 打赏
  • 举报
回复
代码等待中……
lw549 2003-09-08
  • 打赏
  • 举报
回复
代码。。。
goomoo 2003-09-08
  • 打赏
  • 举报
回复
用Delphi 写的肯定要比asm的大不少啦。那个13KB 的是用upx压缩过,未压缩的大小为20K.

呆会儿贴出源代码。其实很简单,就是全部用 api 来写就可以达到很小的尺寸了。
bxh2dai 2003-09-06
  • 打赏
  • 举报
回复
楼主可以给源码吗?
wxjh 2003-09-05
  • 打赏
  • 举报
回复
不会是木马吧?
wxjh 2003-09-05
  • 打赏
  • 举报
回复
运行后没有反应
nzh517 2003-09-05
  • 打赏
  • 举报
回复
我用复制粘贴网上代码用Delphi做了一个小程序:
http://hanlin.hbu.edu.cn/personal/slave/mysoft/ip.exe
只有15.5K

其实不用ASM也可以做得很少,用C就可以,大家试过LCC吗??用它写出来的windows程序和用win32ASM写出来的差不多.
Eastunfail 2003-09-05
  • 打赏
  • 举报
回复
编译后2560字节的GUI程序的代码:

.486
.model flat, stdcall
option casemap:none

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
WinMain PROTO STDCALL :DWORD, :DWORD, :DWORD, :DWORD
WndProc PROTO STDCALL :DWORD, :DWORD, :DWORD, :DWORD
.data?
hInstance dd ?

.data
ClassName db "FirstWindowClass",0
AppName db "FirstWindow",0

.code
start:

invoke GetModuleHandle, NULL
mov hInstance, eax
invoke WinMain, hInstance, NULL, NULL, SW_SHOWNORMAL
invoke ExitProcess, NULL

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL hwnd:DWORD
LOCAL msg:MSG
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc

INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW-WS_SIZEBOX-WS_MAXIMIZEBOX,CW_USEDEFAULT,\
CW_USEDEFAULT,400,300,NULL,NULL,\
hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW
mov eax,msg.wParam
ret
WinMain endp

WndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
mov eax, uMsg
.IF eax==WM_CREATE
invoke MessageBox, NULL, ADDR AppName, ADDR AppName, NULL
.ELSEIF eax==WM_DESTROY
invoke PostQuitMessage, NULL
.ELSE
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
.ENDIF
ret
WndProc endp
end start
solonet 2003-09-05
  • 打赏
  • 举报
回复
还没玩,真的好玩吗?
YYQQ 2003-09-05
  • 打赏
  • 举报
回复
呵呵, 好玩, 不能还原啊
jiwenn 2003-09-05
  • 打赏
  • 举报
回复
没源代码,不看!!!!
bluecyclone 2003-09-05
  • 打赏
  • 举报
回复
API写的吧!看源码!
Xleep 2003-09-05
  • 打赏
  • 举报
回复
是啊直接用win api代码就很小。

13k?难道你是用汇编 + WinApi?
onrush 2003-09-05
  • 打赏
  • 举报
回复
有意思
zhoutian618 2003-09-05
  • 打赏
  • 举报
回复
你应该至少要依赖VCLXX.BPL吧.

除非你自己全部用WIN API 或WIN SDK的东西.
hkbarton 2003-09-05
  • 打赏
  • 举报
回复
不错!期待你的原代码
WGYKING 2003-09-05
  • 打赏
  • 举报
回复
好好玩哦!
Eastunfail 2003-09-05
  • 打赏
  • 举报
回复
昏~~~~用masm写个简单程序,最多不会超过4KB,一个空窗体的也只有1000多字节。还没有压缩过
加载更多回复(22)

828

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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