Mht. at bruge ShellExecute i en DLL - kan du ikke sende et handle med over (som parameter)?
I øvrigt er CreateProcess nok den rigtigste at bruge, idet WinExec er lavet for bagud kompatibilitet med 16-bits programmer. Den tager en masse parametre, og syntaksen er udviklet af Gates under et syretrip der gik galt!
Here goes (
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp):
BOOL CreateProcess(
LPCTSTR lpApplicationName,
LPTSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCTSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
);
Implementeret ser det sådan her ud (
http://www.delphicorner.f9.co.uk/articles/wapi4.htm):
{Supply a fully qualified path name in ProgramName}
procedure ExecNewProcess(ProgramName : String);
var
StartInfo : TStartupInfo;
ProcInfo : TProcessInformation;
CreateOK : Boolean;
begin
{ fill with known state }
FillChar(StartInfo,SizeOf(TStartupInfo),#0);
FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
StartInfo.cb := SizeOf(TStartupInfo);
CreateOK := CreateProcess(PChar(ProgramName),nil, nil, nil,False,
CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
nil, nil, StartInfo, ProcInfo);
{ check to see if successful }
if CreateOK then
//may or may not be needed. Usually wait for child processes
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
end;