Prevent using DeDe software to decompile delphi programs
Here is an article to prevent using DeDe software to decompile delphi programs ~
The ones in "" are my annotations, and the rest are original creations~
PROgram Project1;
Uses
Forms,
windows,
sysutils,
Unit1 In 'Unit1.pas' {Form1},
Unit2 In 'Unit2.pas' {Form2};
Function RegisterServiceProcess(dwProcessId, dwType: dWord): Integer; Stdcall;
External 'kernel32.dll'
{$R *.RES}
Var
HMUTEX: HWND;
RET: INTEGER;
hCurrentWindow: HWnd; //Decompilation required
szText: Array[0..254] Of char; //required for decompilation
Begin
application.Initialize;
APPLICATION.TITLE := 'delphi sunflower collection design: Zhang Guopeng';
RegisterServiceProcess(GetCurrentProcessID, 1); //Let the program disappear in Ctl+Alt+Del.
"We can see that the author used RegisterServiceProcess to register the program as a WINDOWS service program~"
"But everyone knows that this function is included in kernel32 and only works in 98/ME~"
"So don't take this as the key to decompilation, it can be said to be dispensable~"
//Prevent decompilation from starting
hCurrentWindow := GetWindow(APPLICATION.Handle, GW_HWNDFIRST);
"From the above, I know that the author wants to know whether his program window is the top-level window."
While hCurrentWindow <> 0 Do
Begin
If GetWindowText(hCurrentWindow, @szText, 255) > 0 Then
If pos('DeDe', StrPas(@szText)) <> 0 Then
"If not, get the title of the current desktop form and determine whether it is "DeDe""
Begin
APPLICATION.MESSAGEBOX('Want to decompile me? It's not that easy!',
'Haha...you guy! ', mb_ok);
//closewindow(hCurrentWindow);//Minimize the program window
enablewindow(hCurrentWindow, false);
//Make the program's window unactivated. If you can get the thread ID number of the program, you can make the program unusable and unclosable. Cool, right?
"The above two sentences are the treatment of DEDE~"
"closewindow: To minimize the specified window, but the window will not be cleared from the memory~"
"Enablewindow: Allow/disable mouse and keyboard input in the specified window, false will definitely not work~"
halt;
End;
hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
End;
//Prevent decompilation from ending
//Prevent the program from running twice
HMUTEX := CREATEMUTEX(Nil, FALSE, 'delphi Sunflower Collection Design: Zhang Guopeng');
RET := GETLASTERROR;
If RET <> ERROR_ALREADY_EXISTS Then
Begin
Application.CreateForm(TForm1, Form1);
// Application.CreateForm(TForm2, Form2);
Application.Run;
End
Else
APPLICATION.MESSAGEBOX('The program has been run!', 'Prompt', mb_ok);
releasemutex(hmutex);
End.