// Import WINAPI import win32.windows; // Core API import core.runtime; import std.range; import std.string; // FMOD import fmod.fmod; extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int result; void exceptionHandler(Throwable e) { throw e; } try { Runtime.initialize(&exceptionHandler); result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow); Runtime.terminate(&exceptionHandler); } catch (Error o) { MessageBoxA(null, cast(char *) o.toString(), "Error", MB_OK | MB_ICONEXCLAMATION); result = 0;// failed } return result; } int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Foo foo = new Foo; return (foo !is null); } class Foo { public: this() { FMOD_SYSTEM * m_system; FMOD_SOUND * m_sound; if(FMOD_System_Create(&m_system) != FMOD_RESULT.FMOD_OK) throw new Error("Failed to create fmod system."); if(FMOD_System_Init(m_system, 2, FMOD_INIT_NORMAL, null) != FMOD_RESULT.FMOD_OK) throw new Error("Failed to initialize fmod."); if(FMOD_System_CreateSound(m_system, cast(char *) r"C:\acdc.ogg", FMOD_HARDWARE | FMOD_LOOP_OFF, null, &m_sound) != FMOD_RESULT.FMOD_OK) throw new Error("Failed to create sound."); // Release Sound FMOD_Sound_Release(m_sound); // Close and release system FMOD_System_Close(m_system); FMOD_System_Release(m_system); } ~this() { MessageBoxA(null, "Called", "Error", MB_OK | MB_ICONEXCLAMATION); } }