[CPP]View Plaincopy
- Add the EXE as a resource, then release it, and run
- Try
- {
- hrsrc hres = FindResource (NULL, Makeintresource (idr_exe1), _t ("EXE"));
- if (NULL = = hres)
- return;
- DWORD dwsize = Sizeofresource (NULL, hres);
- if (0 = = dwsize)
- return;
- hglobal hglobal = LoadResource (NULL, hres);
- if (NULL = = hglobal)
- return;
- LPVOID LP = Lockresource (HGLOBAL);
- if (NULL = = LP)
- return;
- CFile file;
- TCHAR Szapp[max_path] = {_t ("F://11.exe")};
- File. Open (Szapp, Cfile::modecreate | Cfile::modewrite);
- File. WRITEHUGE (LP, dwsize);
- File. Close ();
- FreeResource (HGLOBAL);
- if (pathfileexists (Szapp))
- {
- Startupinfo si = {sizeof (SI)};
- process_information pi = {0};
- if (CreateProcess (null, SZAPP, NULL, NULL, FALSE, 0, NULL, NULL, &SI, &PI))
- {
- CloseHandle (Pi.hthread);
- CloseHandle (pi.hprocess);
- }
- }
- }
- catch (cexception* e)
- {
- E->reporterror ();
- E->delete ();
- }
Use EXE as a resource, then release to disk and run the EXE program