function CreateProcessInjectA(lpApplicationName: PAnsiChar;
lpCommandLine: PAnsiChar;
lpProcessAttributes: PSecurityAttributes;
lpThreadAttributes: PSecurityAttributes;
bInheritHandles: BOOL;
dwCreationFlags: DWORD;
lpEnvironment: Pointer;
lpCurrentDirectory: PAnsiChar;
const lpStartupInfo: _STARTUPINFOA;
lpProcessInfo: PPROCESS_INFORMATION;
lpFullDLLName: PAnsiChar): BOOL; stdcall;
function CreateProcessInjectW(lpApplicationName: PWChar;
lpCommandLine: PWChar;
lpProcessAttributes: PSecurityAttributes;
lpThreadAttributes: PSecurityAttributes;
bInheritHandles: BOOL;
dwCreationFlags: DWORD;
lpEnvironment: Pointer;
lpCurrentDirectory: PWChar;
const lpStartupInfo: _STARTUPINFOW;
lpProcessInfo: PPROCESS_INFORMATION;
lpFullDLLName: PWChar): BOOL; stdcall;
var
siW: STARTUPINFOW;
pi: PROCESS_INFORMATION;
begin
ZeroMemory(@siW, sizeof(siW));
siW.cb := sizeof(siW);
if CreateProcessInjectW(nil, 'notepad.exe', nil, nil, False, 0, nil, nil, siW, @pi, PWChar('C:\DLL.dll')) then
begin
ShowMessage('Process successfully created and injected!');
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
end
else
ShowMessage('Process injection failed!');
end;