Example Code

function GetCommandLineExW(const hProcess: THandle; lpCommandLine: PWChar; dwChMaxLen: DWORD): BOOL; stdcall; function GetCommandLineExA(const hProcess: THandle; lpCommandLine: PAnsiChar; dwChMaxLen: DWORD): BOOL; stdcall; // Extension of kernel32!GetCommandLine() which works with remote processes var lpCmdLineW: Array [0..4095] of WChar; begin // NULL terminator appended implicitly to result buffer if GetCommandLineExW(GetCurrentProcess(), @lpCmdLineW, 4096) then MessageBoxW(0, @lpCmdLineW, 'CmdLine', MB_ICONINFORMATION) else MessageBoxW(0, 'Failed to retrieve command line', nil, MB_ICONERROR); end;