Code:
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
WCHAR modPath[MAX_PATH];
if (!GetModuleFileName(nullptr, modPath, MAX_PATH))
{
MessageBox(nullptr, L"GetModuleFileName failed o_O", nullptr, MB_OK | MB_ICONERROR);
return 1;
}
if (!PathRemoveFileSpec(modPath))
{
MessageBox(nullptr, L"PathRemoveFileSpec failed o_O", nullptr, MB_OK | MB_ICONERROR);
return 2;
}
if (!SetCurrentDirectory(modPath))
{
MessageBox(nullptr, L"SetCurrentDirectory failed o_O", nullptr, MB_OK | MB_ICONERROR);
return 3;
};
HINSTANCE res = ShellExecute(nullptr, L"open", L"AutoIt3.exe", L"mmanager.au3", nullptr, SW_NORMAL);
if (res > HINSTANCE(32))
return 0;
DWORD error = GetLastError();
if (!error)
return 0;
LPVOID lpMsgBuf;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error, 0, (LPTSTR)&lpMsgBuf, 0, nullptr))
MessageBox(nullptr, (LPCTSTR)lpMsgBuf, nullptr, MB_OK | MB_ICONERROR);
LocalFree(lpMsgBuf);
return 4;
}