int WINAPI WinMain(HINSTANCE inst,HINSTANCE prev,LPSTR cline,int cshow){ WNDCLASS kscls={CS_OWNDC,MainProc,0,0,inst,LoadIcon(inst,MAKEINTRESOURCE(ICO_ICON)),LoadCursor(0,IDC_ARROW),0,0,"kscls"}; WNDCLASS bncls={CS_OWNDC,BtnProc,0,0,inst,0,LoadCursor(0,IDC_ARROW),0,0,"bncls"}; unsigned long i=0; MSG msg; // InitCommonControls(); __try{ // Start exceptionable code // Register classes RegisterClass(&kscls); RegisterClass(&bncls); // Generate INI path vr.ini=calloc(MAX_PATH,sizeof(char)); GetModuleFileName(GetModuleHandle(0),vr.ini,MAX_PATH); *(strrchr(vr.ini,'\\')+sizeof(char))='\0'; strncat(vr.ini,"KwikStrip-",MAX_PATH-strlen(vr.ini)); i=MAX_PATH-strlen(vr.ini); GetUserName(&vr.ini[strlen(vr.ini)],&i); strncat(vr.ini,".ini",MAX_PATH-strlen(vr.ini)); vr.ini=realloc(vr.ini,strlen(vr.ini)+1); // Create window do{switch(Config_Load()){ // Main program loop case KS_INI_NONE: if(MessageBox(HWND_DESKTOP,"This appears to be the first time you have run KwikStrip.\nYou need to set it up.\n\nOpen the config dialog now?","KwikStrip: Welcome!",MB_YESNO|MB_ICONINFORMATION)==IDYES){ DialogBox(GetModuleHandle(0),MAKEINTRESOURCE(DLG_CONFIG),HWND_DESKTOP,ConfigProc); msg.wParam=KS_EXIT_RESTART; continue; // Try to load the config again }else{msg.wParam=0;} break; case KS_INI_NOBT: if(MessageBox(HWND_DESKTOP,"It appears that you have no buttons defined.\nYou need to add at least one for KwikStrip to operate properly.\n\nOpen the config dialog?","KwikStrip: No button definitions!",MB_YESNO|MB_ICONEXCLAMATION|MB_ICONQUESTION)==IDYES){ DialogBox(GetModuleHandle(0),MAKEINTRESOURCE(DLG_CONFIG),HWND_DESKTOP,ConfigProc); msg.wParam=KS_EXIT_RESTART; continue; // Try to load the config again }else{msg.wParam=0;} break; default: // Start normally vr.wnd=CreateWindowEx(WS_EX_TOOLWINDOW|(cf.disp==KS_DSP_TOP?WS_EX_TOPMOST:0),"kscls",STR_TITLE,WS_VISIBLE|WS_POPUP|WS_CLIPCHILDREN,0,0,0,0,HWND_DESKTOP,0,inst,0); while(GetMessage(&msg,0,0,0)){TranslateMessage(&msg);DispatchMessage(&msg);} // Delete stuff DestroyWindow(vr.wnd); DeleteDC(vr.gfx); do{Cfg_DeleteItem(0);}while(vr.btns); DeleteObject(SelectObject(vr.gfx,0)); free(itm); free(cf.fnt); break; }}while(msg.wParam==KS_EXIT_RESTART); free(vr.ini); return msg.wParam; // Crash handler }__except(DialogBoxParam(GetModuleHandle(0),MAKEINTRESOURCE(DLG_CRASH),vr.wnd,CrashProc,(LPARAM)GetExceptionInformation())?EXCEPTION_EXECUTE_HANDLER:EXCEPTION_EXECUTE_HANDLER){ return 1; } }
int main(void) { /* Print info */ write("$IOSVersion: ESP: " __DATE__ " " __TIME__ " 64M$\n"); /* Load config */ Config_Load(&config, sizeof(config)); /* Get IOS info */ Swi_GetIosInfo(&ios); /* Initialize plugin */ Swi_CallFunc((void *)__ES_System, NULL, NULL); return 0; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { RUNNING = RUN_NONE; //GetCommandLine() -> Path (in quotes) + Arguments //lpCmdLine -> Arguments //Get bios folder //--------------- strcpy(biospath,GetCommandLine()); //For WINE compatibility? ---------------------------- char quotescharacter = '\0'; if(biospath[0] == '\"') quotescharacter = '\"'; else if(biospath[0] == '\'') quotescharacter = '\''; //---------------------------------------------------- //get emulator folder int i = 1; if(biospath[0] == quotescharacter) { int len = strlen(biospath) - 1; int j; for(j = 0; j < len; j++) biospath[j] = biospath[j+1]; while( (biospath[i++] != quotescharacter) && (i < MAXPATHLEN) ); } else while( (biospath[i++] != ' ') && (i < MAXPATHLEN) ); if( i == MAXPATHLEN ) { //#ifdef WIN32 //MessageBox(NULL,"Error while parsing command line.","Command Line",MB_OK); //#endif return 0; } while( (biospath[i--] != '\\') && (i > 0) ); biospath[i+1] = '\0'; strcpy(runningfolder,biospath); Config_Load(); strcat(biospath,"\\bios"); atexit(atexit_fn); //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- if(!GLWindow_Create()) return 0; #ifdef ENABLE_SPLASH GLWindow_SplashScreen(); #endif if(CSoundServer_open(SoundCallback,EmulatorConfig.server_buffer_len) == 0) ErrorMessage("Couldn't init sound system!"); if(strlen(lpCmdLine) != 0) { char rompath[MAXPATHLEN]; strcpy(rompath,lpCmdLine); if(rompath[0] == quotescharacter) { int len = strlen(rompath) - 2; int j; for(j = 0; j < len; j++) rompath[j] = rompath[j+1]; rompath[j] = '\0'; } GLWindow_LoadRom(rompath); } GLWindow_Mainloop(); GLWindow_Kill(); //CSoundServer_close(); //Crashes... return 0; }
int main(int argc, char *args[]) { Config config; Config_Init(&config); if( !Config_FromArgs(&config, argc, args) ) return 1; Config_Load(&config, config.configFile); Config_Check(&config); Config_Print(config); MD3Model model; model.scale = config.model_scale; model.fps = config.fps; MD3Anims anims; anims.n_anims = 0; anims.anims = NULL; if( config.redirect2File ) { if( config.stdoutFile ) freopen(config.stdoutFile, "w+", stdout); if( config.stderrFile ) freopen(config.stderrFile, "w+", stderr); } model.path = Utils_GetPath(config.modelFile); if( MD3Viewer_Init(&config) ) { if( config.modelFile != NULL && MD3Loader_Load(&model, config.modelFile) ) { if( config.debug ) { MD3Verbose_PrintModelInfo(&model); } if( !config.info ) { MD3Viewer_SetModel(&model); if( config.animFile != NULL ) { if( MD3Anim_Load(config.animFile, &anims) ) MD3Viewer_SetAnims(&anims); else fprintf(stderr, "Failed to load animation file: '%s'\n", config.animFile); } #ifdef DMALLOC debugmalloc_naplofajl("memlog.txt"); debugmalloc_dump(); #endif MD3Viewer_Start(); MD3Viewer_Quit(); } MD3Loader_FreeModel(&model); if( config.animFile != NULL ) MD3Anim_FreeAnims(&anims); } else fprintf(stderr, "Failed to load modell!\n"); } else fprintf(stderr, "Failed to init viewer!\n"); if( config.redirect2File ) { if( config.stdoutFile ) fclose(stdout); if( config.stderrFile ) fclose(stderr); } return 0; }
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { enum { WM_APP_TRAYICON = WM_APP_RELOAD + 1, }; static NOTIFYICONDATA nid; static HMENU hMenu; switch (uMsg) { case WM_APP_TRAYICON: switch (lParam) { case WM_RBUTTONDOWN: SetCapture(hWnd); break; case WM_RBUTTONUP: ReleaseCapture(); { RECT rc; POINT pt; GetCursorPos(&pt); GetWindowRect(GetDesktopWindow(), &rc); SetForegroundWindow(hWnd); TrackPopupMenu(GetSubMenu(hMenu, 0), (pt.x < (rc.left + rc.right) / 2 ? TPM_LEFTALIGN : TPM_RIGHTALIGN) | (pt.y < (rc.top + rc.bottom) / 2 ? TPM_TOPALIGN : TPM_BOTTOMALIGN) | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hWnd, NULL); PostMessage(hWnd, WM_NULL, 0, 0); } break; case NIN_BALLOONHIDE: case NIN_BALLOONTIMEOUT: case NIN_BALLOONUSERCLICK: /* error message closed */ DestroyWindow(hWnd); break; } return 0; case WM_APP_RELOAD: { Config_Load(); } return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_CONF: { TCHAR cmd[MAX_PATH]; GetModuleFileName(NULL, cmd, ARRAYSIZE(cmd)); lstrcpy(cmd + lstrlen(cmd) - 4, TEXT("cf")); Exec(cmd); } break; case ID_QUIT: DestroyWindow(hWnd); break; } break; case WM_CREATE: { HINSTANCE hInstance = ((LPCREATESTRUCT)lParam)->hInstance; Config_Load(); /* menu */ hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDM_MAIN)); /* tray icon */ ZeroMemory(&nid, sizeof nid); nid.cbSize = sizeof nid; nid.hWnd = hWnd; nid.uID = 100; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uCallbackMessage = WM_APP_TRAYICON; nid.hIcon = Global.hIconLarge; lstrcpy(nid.szTip, App.Title); Shell_NotifyIcon(NIM_ADD, &nid); /* error message balloon tip */ nid.uFlags = NIF_INFO; nid.dwInfoFlags = NIIF_WARNING; LoadString(hInstance, IDS_DEVICE_NOT_FOUND, nid.szInfo, ARRAYSIZE(nid.szInfo)); lstrcpy(nid.szInfoTitle, App.Title); /* low level keyboard hook */ Global.hHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hInstance, 0); if (!SpecialKey_Prepare()) Shell_NotifyIcon(NIM_MODIFY, &nid); } break; case WM_DESTROY: { SpecialKey_Cleanup(); UnhookWindowsHookEx(Global.hHook); Shell_NotifyIcon(NIM_DELETE, &nid); DestroyMenu(hMenu); } PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, uMsg, wParam, lParam); }