by the way i try your code i change value myapp.exe to cmd.exe and param 1 param 2 to ver.
so the code like this
#include <windows.h>
#include <tchar.h>
DWORD CALLBACK RunMyApp(LPVOID lpParam)
{
STARTUPINFO Si = { sizeof(Si) };
PROCESS_INFORMATION Pi = { 0 };
if(CreateProcess(_T("cmd.exe"), _T("cmd.exe ver"), NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi))
{
CloseHandle(Pi.hThread);
CloseHandle(Pi.hProcess);
}
return 0;
}
BOOL CALLBACK DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
{
DWORD dwThreadId;
HANDLE hThread = CreateThread(NULL, 0, &RunMyApp, NULL, 0, &dwThreadId);
if(hThread)
{
CloseHandle(hThread);
}
break;
}
}
return TRUE;
}
and try to execute it directly from cmd.exe. the dll not call new cmd.exe with value ver to check ver cmd.exe.
whats going on?