亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 編程 > Delphi > 正文

一個只有17K的Delphi字符串加密程序源碼

2019-11-18 17:58:49
字體:
來源:轉載
供稿:網友

PRogram Window;

{
   This is an example of making an application
   without using the Forms unit. Forms.pas is the
   Delphi unit that makes your programs so damn
   huge! Forms.pas has all the code for translating
   the forms you create with Delphi w/components
   into windows. If you ask me, anything that adds
   200k(@%#$!) to your app has got to be some damn
   inefficient code.

   GoRDy <gfody@jps.net>
   www.jps.net/gfody
}


uses Windows, Messages;

{$R *.RES}

var
wClass:   TWndClass;  // class struct for main window
hFont,                // handle of font
hInst,                // handle of program (hinstance)
Handle,               // handle of main window
hEncrypt,             // handle of encrypt button
hDecrypt,             // handle of decrypt button
hEdit,                // handle of main edit
hLabel,               // handle of passWord label
hPW:      HWND;       // handle of password edit
Msg:      TMSG;       // message struct
dEncrypt,
dDecrypt: Pointer;    // default button procedures

(*------------------------------------------------*)

// This lines everything up
procedure Resize;
var
RCT:TRect;
begin
  GetWindowRect(Handle,RCT);
  MoveWindow(hPW,230,5,RCT.Right-RCT.Left-245,24,True);
  MoveWindow(hEdit,5,34,RCT.Right-RCT.Left-20,RCT.Bottom-RCT.Top-66,True);
end;

(*------------------------------------------------*)

// This is to cleanup and stop the program
procedure ShutDown;
begin
  DeleteObject(hFont);
  UnRegisterClass('Sample Class',hInst);
  ExitProcess(hInst); //end program
end;

(*------------------------------------------------*)

// Decrypts the text in hEdit with the text in hPW
procedure Decrypt;
var
x,i,                // count variables
sText,sPW: Integer; // size of Text, PW
Text,PW:   PChar;   // buffer for Text, PW
begin
  sText:=GetWindowTextLength(hEdit)+1;
  sPW:=GetWindowTextLength(hPW)+1;
  GetMem(Text,sText);
  GetMem(PW,sPW);
  GetWindowText(hEdit,Text,sText);
  GetWindowText(hPW,PW,sPW);
  x:=0; // initialize count
  for i:=0 to sText-2 do
  begin
    Text[i]:=Chr(Ord(Text[i])-Ord(PW[x]));
    Inc(x);
    if x=(sPW-1)then x:=0;
  end;
  SetWindowText(hEdit,Text);
  FreeMem(Text);
  FreeMem(PW);
end;

(*------------------------------------------------*)

// Encrypts the text in hEdit with the text in hPW
procedure Encrypt;
var
x,i,                // count variables
sText,sPW: Integer; // size of Text, PW
Text,PW:   PChar;   // buffer for Text, PW
begin
  sText:=GetWindowTextLength(hEdit)+1;
  sPW:=GetWindowTextLength(hPW)+1;
  GetMem(Text,sText);
  GetMem(PW,sPW);
  GetWindowText(hEdit,Text,sText);
  GetWindowText(hPW,PW,sPW);
  x:=0; // initialize count
  for i:=0 to sText-2 do
  begin
    Text[i]:=Chr(Ord(Text[i])+Ord(PW[x]));
    Inc(x);
    if x=(sPW-1)then x:=0;
  end;
  SetWindowText(hEdit,Text);
  FreeMem(Text);
  FreeMem(PW);
end;

(*------------------------------------------------*)

// This function processes every message sent to the Encrypt Button
function EncryptProc(hWnd,Msg,wParam,lParam:Longint):Longint; stdcall;
var
i: Integer;
begin
  // Always pass the message to the Default procedure
  Result:=CallWindowProc(dEncrypt,hWnd,Msg,wParam,lParam);

  case Msg of
  // If the user presses TAB we're gunna switch the
  // focus over to the Decrypt button.
  WM_KEYDOWN: if wParam=9 then SetFocus(hDecrypt);
  end;

end;

(*------------------------------------------------*)

// This function processes every message sent to the Decrypt Button
function DecryptProc(hWnd,Msg,wParam,lParam:Longint):Longint; stdcall;
begin
  // Always pass the message to the Default procedure
  Result:=CallWindowProc(dEncrypt,hWnd,Msg,wParam,lParam);

  case Msg of
  // if the user presses TAB we're gunna switch
  // the focus back to the Encrypt button.
  WM_KEYDOWN: if wParam=9 then SetFocus(hEncrypt);
  end;

end;

(*------------------------------------------------*)

// This function processes every message sent to our Main window
function WindowProc(hWnd,Msg,wParam,lParam:Longint):Longint; stdcall;
begin
  // Always pass the message to the Default procedure
  Result:=DefWindowProc(hWnd,Msg,wParam,lParam);

  case Msg of
  WM_SIZE:    Resize;
  // When buttons are clicked the message is passed to
  // the parent window, so we handle it here.
  WM_COMMAND: if      lParam=hEncrypt then Encrypt
              else if lParam=hDecrypt then Decrypt;
  WM_DESTROY: ShutDown;
  end;

end;

(*------------------------------------------------*)

// This is the main program function (WinMain)
begin

  hInst:=GetModuleHandle(nil); // get the application instance
                               // hInstance returns zilch

  with wClass do
  begin
    Style:=         CS_PARENTDC;
    hIcon:=         LoadIcon(hInst,'MAINICON');
    lpfnWndProc:=   @WindowProc;
    hInstance:=     hInst;
    hbrBackground:= COLOR_BTNFACE+1;
    lpszClassName:= 'Sample Class';
    hCursor:=       LoadCursor(0,IDC_ARROW);
  end;

  // Once our class is registered we
  // can start making windows with it
  RegisterClass(wClass);

  // Create our main window
  Handle:=CreateWindow(
    'Sample Class',          // Registered Class Name
    'Encrypter - By: GoRDy', // Title of Window
    WS_OVERLAPPEDWINDOW or   // Basic Window Style
    WS_VISIBLE,              // Make it Visible
    10,                      // Left
    10,                      // Top
    400,                     // Width
    300,                     // Height
    0,                       // Parent Window Handle
    0,                       // Handle of Menu
    hInst,                   // Application Instance
    nil);                    // Structure for Creation Data

  // Create the Encrypt button
  hEncrypt:=CreateWindow(
    'Button',
    'Encrypt',
    WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT,
    5,5,65,24,Handle,0,hInst,nil);

  // Create the Decrypt button
  hDecrypt:=CreateWindow(
    'Button',
    'Decrypt',
    WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT,
    75,5,65,24,Handle,0,hInst,nil);

  // Create the main Edit
  hEdit:=CreateWindowEx(
    WS_EX_CLIENTEDGE, // this EX style is for the beveled edge
    'Edit',
    '',
    WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or ES_WANTRETURN or ES_AUTOVSCROLL or WS_VSCROLL,
    5,34,380,234,Handle,0,hInst,nil);

  // Create the password Edit
  hPW:=CreateWindowEx(
    WS_EX_CLIENTEDGE,
    'Edit',
    '',
    WS_VISIBLE or WS_CHILD or ES_LEFT or ES_AUTOHSCROLL or ES_PASSWORD,
    230,5,155,24,Handle,0,hInst,nil);

  hLabel:=CreateWindow(
    'Static',
    'Password:',
    WS_VISIBLE or WS_CHILD or SS_LEFT,
    160,10,70,20,Handle,0,hInst,nil);

  // Create a custom font for our window otherwise
  // everything would use the system font (blech!)
  hFont:=CreateFont(
    -12,                           // Height
    0,                             // Width
    0,                             // Angle of Rotation
    0,                             // Orientation
    0,                             // Weight
    0,                             // Italic
    0,                             // Underline
    0,                             // Strike Out
    DEFAULT_CHARSET,               // Char Set
    OUT_DEFAULT_PRECIS,            // Precision
    CLip_DEFAULT_PRECIS,           // Clipping
    DEFAULT_QUALITY,               // Render Quality
    DEFAULT_PITCH or FF_DONTCARE,  // Pitch & Family
    'MS Sans Serif');              // Font Name

  // Set the fonts for all our controls
  SendMessage(hEncrypt,WM_SETFONT,hFont,0);
  SendMessage(hDecrypt,WM_SETFONT,hFont,0);
  SendMessage(hEdit,WM_SETFONT,hFont,0);
  SendMessage(hPW,WM_SETFONT,hFont,0);
  SendMessage(hLabel,WM_SETFONT,hFont,0);

  // Subclass Encrypt Button (assign it a custom WindowProc)
  dEncrypt:=Pointer(GetWindowLong(hEncrypt,GWL_WNDPROC));
  SetWindowLong(hEncrypt,GWL_WNDPROC,Longint(@EncryptProc));

  // Subclass Decrypt Button
  dDecrypt:=Pointer(GetWindowLong(hDecrypt,GWL_WNDPROC));
  SetWindowLong(hDecrypt,GWL_WNDPROC,Longint(@DecryptProc));

  // The reason I don't subclass the Edit controls here
  // is because they don't do anything custom. If I wanted
  // them to Beep or something whenever you typed a "G" then
  // I would subclass them.

  // Focus on first control (otherwise people with no mouse are screwed)
  SetFocus(hEncrypt);

  // Now we loop GetMessage to process each Message in
  // our main window's message list. Every time the main
  // window recieves a message its added to the list, so
  // this loop here will eventually process it.

  while(GetMessage(Msg,Handle,0,0))do
  begin
    TranslateMessage(Msg);             // Translate any keyboard Msg's
    DispatchMessage(Msg);              // Send it to our WindowProc
  end;                                 // for processing.

end.



上一篇:Delphi與DirectShow&amp;amp;DSPack/在Delphi7.0下安裝DSPack

下一篇:Delphi中預編譯指令如何使用

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
色中色综合影院手机版在线观看| 欧美中文字幕在线观看| 久久久成人av| 久久久久久综合网天天| 久久人人爽人人爽人人片av高清| 日本在线观看天堂男亚洲| 久久精品国产一区二区电影| 欧美与黑人午夜性猛交久久久| 国产中文日韩欧美| 日韩av在线影视| xxxx欧美18另类的高清| www.久久色.com| 97在线视频观看| 亚洲一区二区久久久久久| 555www成人网| 日韩精品亚洲元码| 91免费版网站入口| 精品亚洲永久免费精品| 亚洲一区二区自拍| 91精品在线观看视频| 亚洲第一级黄色片| 影音先锋欧美精品| 欧美亚洲国产日本| 亚洲日韩中文字幕| 国内外成人免费激情在线视频网站| 国产成人精品在线观看| 92看片淫黄大片欧美看国产片| 亚洲第一区第二区| 亚洲欧美日韩另类| 成人网中文字幕| 国内伊人久久久久久网站视频| 亚洲深夜福利视频| 欧美日韩免费区域视频在线观看| 免费91麻豆精品国产自产在线观看| 孩xxxx性bbbb欧美| 国产精品视频精品视频| 亚洲最大成人在线| 国产99久久精品一区二区永久免费| 一本久久综合亚洲鲁鲁| 欧美国产日韩xxxxx| 国产在线视频2019最新视频| 欧美在线播放视频| 欧美精品一区二区三区国产精品| 欧美黄色成人网| 在线精品视频视频中文字幕| 少妇高潮久久久久久潘金莲| 国产亚洲成av人片在线观看桃| 国产精品美腿一区在线看| 91国产精品91| 亚洲成人中文字幕| 国产成人拍精品视频午夜网站| 国产精品亚洲精品| 成人在线免费观看视视频| 成人激情视频免费在线| 欧美成人sm免费视频| 国产日韩在线播放| 91色在线视频| 国产日韩欧美在线看| 国产精品成av人在线视午夜片| 久久久久国产精品免费| 国产成人综合一区二区三区| 亚洲福利精品在线| 亚洲男人天堂2019| 欧美自拍视频在线观看| 日韩av电影国产| 国产一区二区三区视频在线观看| 亚洲国产天堂久久综合网| 久久天天躁狠狠躁夜夜躁| 日韩精品欧美激情| 欧美成人免费在线视频| 欧美日韩中文在线观看| 欧美亚洲一级片| 欧美午夜宅男影院在线观看| 日韩欧美第一页| 深夜福利亚洲导航| 欧美超级乱淫片喷水| 欧美黄网免费在线观看| 久久亚洲精品一区| 亚洲美女视频网站| 成人av番号网| 黑人极品videos精品欧美裸| 亚洲毛茸茸少妇高潮呻吟| 亚洲午夜av久久乱码| 国产精品成av人在线视午夜片| 亚洲天堂av网| 色先锋资源久久综合5566| 国产精品第三页| 大荫蒂欧美视频另类xxxx| 日韩免费在线免费观看| 中文字幕欧美日韩va免费视频| 韩国视频理论视频久久| 久久亚洲精品成人| 97在线免费观看视频| 69av视频在线播放| 国产丝袜一区二区三区免费视频| 国产精品无码专区在线观看| 亚洲成色777777女色窝| 久久免费少妇高潮久久精品99| 日韩精品高清在线| 激情成人中文字幕| 欧美性受xxxx白人性爽| 亚洲精品国产精品国自产观看浪潮| 国产99视频在线观看| 欧美日韩加勒比精品一区| 亚洲成人免费网站| 亚洲最新在线视频| 成人有码在线视频| 国产丝袜一区二区三区免费视频| 日韩在线免费观看视频| 91免费福利视频| 亚洲韩国青草视频| 亚洲韩国青草视频| 午夜精品www| 国产精品日日摸夜夜添夜夜av| 日韩欧美999| 日韩大片免费观看视频播放| 97超碰国产精品女人人人爽| 中文字幕欧美日韩| 精品福利免费观看| 亚洲精品视频二区| 欧美成人精品激情在线观看| 欧美日韩在线另类| 亚州成人av在线| 欧美xxxx做受欧美| 国产精品久久精品| 亚洲毛片在线免费观看| 国产成人精品日本亚洲专区61| 国产精品一二区| 中文字幕在线看视频国产欧美在线看完整| 日韩精品中文在线观看| 国产99久久久欧美黑人| 国产视频久久久| 亚洲激情成人网| 亚洲一区二区三区四区在线播放| 国产欧美精品va在线观看| 亚洲福利在线观看| 88国产精品欧美一区二区三区| 亚洲午夜av久久乱码| 激情久久av一区av二区av三区| 伊人久久大香线蕉av一区二区| 中文字幕亚洲欧美日韩高清| 在线成人激情黄色| 久久国产精品网站| 欧美风情在线观看| 最近2019中文字幕mv免费看| 国内免费久久久久久久久久久| 成人羞羞国产免费| 日韩的一区二区| 国产精品爽黄69天堂a| 2019中文字幕免费视频| 欧美性视频精品| 日韩av网址在线观看| 精品久久久久久中文字幕大豆网| 亚洲第一区中文99精品| 国产视频综合在线| 国产欧美日韩综合精品| 国产精品小说在线| 欧美中文在线字幕| 91人成网站www| 欧美—级a级欧美特级ar全黄| 91高清视频免费| 亚洲美女黄色片| 成人免费视频网址| 亚洲国产第一页|