黑客帝国屏保源码

黑客帝国屏幕保护设置

1. 打开VS2010或以上版本,新建—>项目,Visual C++,win32,选择win32控制台应用程序,名称填写为”hacker”。

2. 将一下代码复制到项目源文件中

黑客帝国屏保源码

  1. //数字流星雨 作者:Wicrecend
  2. #include "stdafx.h"
  3. #include <windows.h>
  4. #define ID_TIMER 1
  5. #define STRMAXLEN 25 //一个显示列的最大长度
  6. #define STRMINLEN 8 //一个显示列的最小长度
  7. LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
  8. //////////////////////////////////////////////////////////////////
  9. //////////////////////////////////////////////////////////////////
  10. typedef struct tagCharChain //整个当作屏幕的一个显示列,这是个双向列表
  11. {
  12. struct tagCharChain *prev; //链表的前个元素
  13. TCHAR ch; //一个显示列中的一个字符
  14. struct tagCharChain *next; //链表的后个元素
  15. }CharChain, *pCharChain;
  16. typedef struct tagCharColumn
  17. {
  18. CharChain *head, *current, *point;
  19. int x, y, iStrLen; //显示列的开始显示的x,y坐标,iStrLen是这个列的长度
  20. int iStopTimes, iMustStopTimes; //已经停滞的次数和必须停滞的次数,必须停滞的次数是随机的
  21. }CharColumn, *pCharColumn;
  22. int main(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  23. PSTR szCmdLine, int iCmdShow)
  24. {
  25. static TCHAR szAppName[] = TEXT ("matrix") ;
  26. HWND hwnd ;
  27. MSG msg ;
  28. WNDCLASS wndclass ;
  29. wndclass.style = CS_HREDRAW | CS_VREDRAW ;
  30. wndclass.lpfnWndProc = WndProc ;
  31. wndclass.cbClsExtra = 0 ;
  32. wndclass.cbWndExtra = 0 ;
  33. wndclass.hInstance = hInstance ;
  34. wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
  35. wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
  36. wndclass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH) ;
  37. wndclass.lpszMenuName = NULL ;
  38. wndclass.lpszClassName = szAppName ;
  39. if(!RegisterClass (&wndclass))
  40. {
  41. MessageBox (NULL, TEXT ("此程序必须运行在NT下!"), szAppName, MB_ICONERROR) ;
  42. return 0;
  43. }
  44. hwnd = CreateWindow (szAppName, NULL,
  45. WS_DLGFRAME | WS_THICKFRAME | WS_POPUP,
  46. 0, 0,
  47. GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
  48. NULL, NULL, hInstance,
  49. NULL) ;
  50. ShowWindow (hwnd, SW_SHOWMAXIMIZED) ; //最大化显示
  51. UpdateWindow (hwnd) ;
  52. ShowCursor(FALSE); //隐藏鼠标光标
  53. srand ((int) GetCurrentTime ()) ; //初始化随机数发生器
  54. while (GetMessage (&msg, NULL, 0, 0))
  55. {
  56. TranslateMessage (&msg) ;
  57. DispatchMessage (&msg) ;
  58. }
  59. ShowCursor(TRUE); //显示鼠标光标
  60. return msg.wParam ;
  61. }
  62. TCHAR randomChar() //随机字符产生函数
  63. {
  64. return (TCHAR)(rand()%(126-33)+33); //33到126之间
  65. }
  66. int init(CharColumn *cc, int cyScreen, int x) //初始化
  67. {
  68. int j;
  69. cc->iStrLen = rand()%(STRMAXLEN-STRMINLEN) + STRMINLEN; //显示列的长度
  70. cc->x = x+3 ; //显示列的开始显示的x坐标
  71. cc->y =rand()%3?rand()%cyScreen:0; //显示列的开始显示的y坐标
  72. cc->iMustStopTimes = rand()%6 ;
  73. cc->iStopTimes = 0 ;
  74. cc->head = cc->current =
  75. (pCharChain)calloc(cc->iStrLen, sizeof(CharChain)); //生成显示列
  76. for(j=0; j<cc->iStrLen-1; j++)
  77. {
  78. cc->current->prev = cc->point; //cc->point一个显示列的前个元素
  79. cc->current->ch = '';
  80. cc->current->next = cc->current+1; //cc->current+1一个显示列的后个元素
  81. cc->point = cc->current++; //cc->point = cc->current; cc->current++;
  82. }
  83. cc->current->prev = cc->point; //最后一个节点
  84. cc->current->ch = '';
  85. cc->current->next = cc->head;
  86. cc->head->prev = cc->current; //头节点的前一个为此链的最后一个元素
  87. cc->current = cc->point = cc->head; //free掉申请的内存要用current当参数
  88. cc->head->ch = randomChar(); // 对链表头的 元素填充
  89. return 0;
  90. }
  91. LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  92. {
  93. HDC hdc ;
  94. //ctn 用来确定一个显示链是否 向下前进,如果等待次数超过必须等待的次数,ctn就代表要向下前进
  95. int i, j, temp, ctn; //j为一个显示链中除链表头外的在屏幕上显示的y坐标,temp绿色过度到黑色之用
  96. static HDC hdcMem;
  97. HFONT hFont;
  98. static HBITMAP hBitmap;
  99. static int cxScreen, cyScreen; //屏幕的宽度 高度.
  100. static int iFontWidth=10, iFontHeight=15, iColumnCount; //字体的宽度 高度, 列数
  101. static CharColumn *ccChain;
  102. switch (message)
  103. {
  104. case WM_CREATE:
  105. cxScreen = GetSystemMetrics(SM_CXSCREEN) ; //屏幕宽度
  106. cyScreen = GetSystemMetrics(SM_CYSCREEN) ;
  107. SetTimer (hwnd, ID_TIMER, 10, NULL) ;
  108. hdc = GetDC(hwnd);
  109. hdcMem = CreateCompatibleDC(hdc);
  110. hBitmap = CreateCompatibleBitmap(hdc, cxScreen, cyScreen);
  111. SelectObject(hdcMem, hBitmap);
  112. ReleaseDC(hwnd, hdc);
  113. //创建字体
  114. hFont = CreateFont(iFontHeight, iFontWidth-5, 0, 0, FW_BOLD, 0, 0, 0,
  115. DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
  116. DRAFT_QUALITY, FIXED_PITCH | FF_SWISS, TEXT("Fixedsys"));
  117. SelectObject(hdcMem, hFont);
  118. DeleteObject (hFont) ;
  119. SetBkMode(hdcMem, TRANSPARENT); //设置背景模式为 透明
  120. iColumnCount = cxScreen/(iFontWidth*3/2); //屏幕所显示字母雨的列数
  121. ccChain = (pCharColumn)calloc(iColumnCount, sizeof(CharColumn));
  122. for(i=0; i<iColumnCount; i++)
  123. {
  124. init(ccChain+i, cyScreen, (iFontWidth*3/2)*i);
  125. }
  126. return 0 ;
  127. case WM_TIMER:
  128. hdc = GetDC(hwnd);
  129. PatBlt (hdcMem, 0, 0, cxScreen, cyScreen, BLACKNESS) ; //将内存设备映像刷成黑色
  130. for(i=0; i<iColumnCount; i++)
  131. {
  132. ctn = (ccChain+i)->iStopTimes++ > (ccChain+i)->iMustStopTimes;
  133. //
  134. (ccChain+i)->point = (ccChain+i)->head; //point用于遍历整个显示列
  135. //第一个字符显示为 白色
  136. SetTextColor(hdcMem, RGB(255, 255, 255));
  137. TextOut(hdcMem, (ccChain+i)->x, (ccChain+i)->y, &((ccChain+i)->point->ch), 1);
  138. j = (ccChain+i)->y;
  139. (ccChain+i)->point = (ccChain+i)->point->next;
  140. //遍历整个显示列,将这个显示列里的字符从下往上显示
  141. temp = 0 ; //temp绿色过度到黑色之用
  142. while((ccChain+i)->point != (ccChain+i)->head && (ccChain+i)->point->ch)
  143. {
  144. SetTextColor(hdcMem, RGB(0, 255-(255*(temp++)/(ccChain+i)->iStrLen), 0));
  145. TextOut(hdcMem, (ccChain+i)->x, j-=iFontHeight, &((ccChain+i)->point->ch), 1);
  146. (ccChain+i)->point = (ccChain+i)->point->next;
  147. }
  148. if(ctn)
  149. (ccChain+i)->iStopTimes = 0 ;
  150. else continue;
  151. (ccChain+i)->y += iFontHeight; //下次开始显示的y坐标 为当前的y坐标加上 一个字符的高度
  152. //如果开始显示的y坐标减去 整个显示列的长度超过了屏幕的高度
  153. if( (ccChain+i)->y-(ccChain+i)->iStrLen*iFontHeight > cyScreen)
  154. {
  155. free( (ccChain+i)->current );
  156. init(ccChain+i, cyScreen, (iFontWidth*3/2)*i);
  157. }
  158. //链表的头 为此链表的前个元素,因为下次开始显示的时候 就相当与在整个显示列的开头添加个元素,然后在开始往上显示
  159. (ccChain+i)->head = (ccChain+i)->head->prev;
  160. (ccChain+i)->head->ch = randomChar();
  161. }
  162. BitBlt(hdc, 0, 0, cxScreen, cyScreen, hdcMem, 0, 0, SRCCOPY);
  163. ReleaseDC(hwnd, hdc);
  164. return 0;
  165. case WM_RBUTTONDOWN:
  166. KillTimer (hwnd, ID_TIMER) ;
  167. return 0;
  168. case WM_RBUTTONUP:
  169. SetTimer (hwnd, ID_TIMER, 10, NULL) ;
  170. return 0;
  171. //处理善后工作
  172. case WM_KEYDOWN:
  173. case WM_LBUTTONDOWN:
  174. case WM_DESTROY:
  175. KillTimer (hwnd, ID_TIMER) ;
  176. DeleteObject(hBitmap);
  177. DeleteDC(hdcMem);
  178. for(i=0; i<iColumnCount; i++)
  179. {
  180. free( (ccChain+i)->current );
  181. }
  182. free(ccChain);
  183. PostQuitMessage (0) ;
  184. return 0 ;
  185. }
  186. return DefWindowProc (hwnd, message, wParam, lParam) ;
  187. }

3. 编译项目工程

4. 找到生成的exe文件,将exe后缀改为scr(hacker.exe->hacker.scr)

5. 将文件hacker.scr拷贝到C:WindowsSystem32下

6. 鼠标移到桌面,右击,选择个性化,屏幕保护程序,选择hacker。

属于自己的黑客帝国屏幕保护程序就设置成功了!

黑客帝国屏保源码

声明:本站部分文章或资源,整理于网络或由网友提供,主要用于知识性分享与学习用途。若相关内容侵犯了原著者的合法权益,请联系处理。
技术插件&API

魔众工具箱系统

2022-4-24 14:29:20

技术

一起名PHP付费起名网源码系统

2022-4-28 10:26:56

0 条回复 A文章作者 M管理员
欢迎您,新朋友,感谢参与互动!
    暂无讨论,说说你的看法吧