// Run setup.exe after unpacking void EndProgress (COMMAND *cmd) { GUI::EndProgress (cmd); if (*cmd->runme.filename) { // Execute runme in the directory outpath RunProgram (cmd->runme.filename, cmd->outpath.filename, cmd->wipeoutdir); // Wipe outdir after installation was completed if (cmd->wipeoutdir) wipedir (cmd->outpath.filename); } }
BOOL WRRunDHCPClient(const char *pcInterface, BOOL bWait) { if (g_pidDhcpClient != 0) return TRUE; if (RunProgram(&g_pidDhcpClient, "/bin/dhcpc", pcInterface, NULL) == FALSE) return FALSE; if (bWait) { while (GetIPAddress (pcInterface) <= 0) tt_usleep (10000); } return TRUE; }
int main () { struct data d = {1,NULL,NULL,0,0,0,0,0,NULL,NULL}; struct comelem * list = NULL; do { printf ("~"); d.run = CycleOfParce (); if (CreateCommand (&list) == NORMAL_CREATE) { d.list = &list; RunProgram (&d); } CheckZombiez (); } while (d.run); return 0; }
//Nomor 5 I/O Redirection void RunProgram1(char **argv, int stats[], string filein, string fileout){ int newstdin, newstdout; if(stats[0]==1){ //Input redirection on newstdin = open(filein.c_str(), O_RDONLY); close(0); dup(newstdin); close(newstdin); } if(stats[1]==1){ //Output redirection on newstdout = open(fileout.c_str(), O_WRONLY|O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO); close(1); dup(newstdout); close(newstdout); } RunProgram(argv); }
/** * Hauptfunktion von Siedler II.5 Return to the Roots * * @param[in] argc Anzahl übergebener Argumente * @param[in] argv Array der übergebenen Argumente * * @return Exit Status, 0 bei Erfolg, > 0 bei Fehler */ int main(int argc, char** argv) { po::options_description desc("Allowed options"); desc.add_options() ("help,h", "Show help") ("map,m", po::value<std::string>(), "Map to load") ("test", "Run in test mode (shows errors during run)") ; po::positional_options_description positionalOptions; positionalOptions.add("map", 1); po::variables_map options; po::store(po::command_line_parser(argc, argv).options(desc) .positional(positionalOptions).run(), options); po::notify(options); if(options.count("help")) { std::cout << desc << "\n"; return 1; } GLOBALVARS.isTest = options.count("test") > 0; GLOBALVARS.errorOccured = false; int result = RunProgram(options); if(GLOBALVARS.isTest) { if(result || GLOBALVARS.errorOccured) { std::cerr << std::endl << std::endl << "ERROR: Test failed!" << std::endl; if(!result) result = 1; } else std::cout << std::endl << std::endl << "Test passed!" << std::endl; } return result; }
/// WindowsWrapper WinMainWrap /// This function should be called from the user's WinMain Function. /// It handles initiating, running and shutting down the engine and game. /// \param hInstance Handle to the window. /// \param pGame Pointer to an object derived from GameBase. /// \param loadingTexture A image name to be used as the loading screen. /// The texture will be loaded from the default texture directory. This /// parameter can be se to NULL resulting in no loading screen. /// \param shaderDebugging Optional parameter specifying whether or not you /// will be debugging a pixel/vertex shader. Setting this to true will create /// the device in software. This parameter defaults to false. void WindowsWrapper::WinMainWrap(HINSTANCE hInstance, GameBase* pGame, const char* loadingTexture, bool shaderDebugging) { // save pointer to game object derived from class GameBase m_pGame = pGame; // save a global pointer to the game gGameBase = pGame; // save the instance of the window hInstApp = hInstance; // Create the window and initate the engine Initiate(shaderDebugging, loadingTexture); // Run the actual game RunProgram(); // Shutdown the game engine and destroy the window Shutdown(); return; }
/** * This is the main program that is run by the debugger or the robot on boot. **/ int jdgFinalTask_StartupLibraryInit(void) { RunProgram(); return 0; }
LRESULT CALLBACK ProjectProc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { int i; RECT rs; NM_TREEVIEW *nm; DWINFO info; LPNMTVKEYDOWN key; PROJECTITEM *data; TVHITTESTINFO hittest; HWND win; HTREEITEM oldSel; static HCURSOR origCurs; static BOOL dragging; static BOOL inView; static HTREEITEM srcItem, dstItem; switch (iMessage) { LOGFONT lf; case WM_SYSCOMMAND: if (wParam == SC_CLOSE) SendMessage(hwnd, WM_CLOSE, 0, 0); break; // case WM_SETTEXT: // return SendMessage(hwndTab, iMessage, wParam, lParam); case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: SetFocus(hwnd); break; case WM_NOTIFY: nm = (NM_TREEVIEW*)lParam; switch (nm->hdr.code) { case NM_CUSTOMDRAW: return CustomDraw(hwnd, (LPNMTVCUSTOMDRAW)nm); case N_EDITDONE: DoneRenaming(); break; case TVN_BEGINDRAG: GetCursorPos(&hittest.pt); ScreenToClient(prjTreeWindow, &hittest.pt); srcItem = TreeView_HitTest(prjTreeWindow, &hittest); data = GetItemInfo(srcItem); if (data && (data->type == PJ_FILE || data->type == PJ_FOLDER)) { dragging = TRUE; SetCapture(hwnd); origCurs = SetCursor(dragCur); inView = TRUE; } break; case TVN_KEYDOWN: key = (LPNMTVKEYDOWN)lParam; switch (key->wVKey) { case VK_INSERT: if (GetKeyState(VK_CONTROL) &0x80000000) { data = GetItemInfo(prjSelectedItem); if (data) { int msg = -1; switch (data->type) { case PJ_WS: msg = IDM_EXISTINGPROJECT; break; case PJ_PROJ: msg = IDM_NEWFOLDER; break; case PJ_FOLDER: msg = IDM_EXISTINGFILE; break; } if (msg != -1) PostMessage(hwnd, WM_COMMAND, msg, 0); } } else if (GetKeyState(VK_SHIFT) &0x80000000) { data = GetItemInfo(prjSelectedItem); if (data) { int msg = -1; switch (data->type) { case PJ_WS: msg = IDM_NEWPROJECT; break; case PJ_PROJ: msg = IDM_NEWFOLDER; break; case PJ_FOLDER: msg = IDM_NEWFILE_P; break; } if (msg != -1) PostMessage(hwnd, WM_COMMAND, msg, 0); } } else { data = GetItemInfo(prjSelectedItem); if (data && (data->type != PJ_WS)) PostMessage(hwnd, WM_COMMAND, IDM_RENAME, 0); } break; case VK_DELETE: if (!(GetKeyState(VK_CONTROL) &0x80000000) && !(GetKeyState(VK_SHIFT) &0x8000000)) { data = GetItemInfo(prjSelectedItem); if (data && (data->type == PJ_FOLDER || data->type == PJ_FILE)) PostMessage(hwnd, WM_COMMAND, IDM_REMOVE, 0); } break; case VK_RETURN: SendMessage(hwnd, WM_COMMAND, IDM_OPENFILES, 0); break; } break; case NM_DBLCLK: oldSel = prjSelectedItem; GetCursorPos(&hittest.pt); ScreenToClient(prjTreeWindow, &hittest.pt); prjSelectedItem = TreeView_HitTest(prjTreeWindow, &hittest); if (prjSelectedItem) PostMessage(hwnd, WM_COMMAND, IDM_OPENFILES, 0); prjSelectedItem = oldSel; return 0; case NM_RCLICK: GetCursorPos(&hittest.pt); ScreenToClient(prjTreeWindow, &hittest.pt); prjSelectedItem = TreeView_HitTest(prjTreeWindow, &hittest); if (prjSelectedItem) { TreeView_SelectItem(prjTreeWindow, prjSelectedItem); } CreateProjectMenu(); break; case TVN_SELCHANGED: nm = (NM_TREEVIEW*)lParam; prjSelectedItem = nm->itemNew.hItem; if (prjSelectedItem == 0) prjSelectedItem = workArea->hTreeItem; break; case TVN_ITEMEXPANDED: nm = (NM_TREEVIEW *)lParam; data = GetItemInfo(nm->itemNew.hItem); if (data) { if (data->type == PJ_FOLDER) { TV_ITEM setitem; memset(&setitem, 0, sizeof(setitem)); setitem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE; setitem.iImage = setitem.iSelectedImage = nm->action == TVE_EXPAND ? ilfolderOpen : ilfolderClose; setitem.hItem = nm->itemNew.hItem; TreeView_SetItem(prjTreeWindow, &setitem); } if (nm->action == TVE_EXPAND) { data->expanded = TRUE; } else data->expanded = FALSE; return 0; } break; case TVN_DELETEITEM: nm = (NM_TREEVIEW *)lParam; if (nm->itemOld.hItem == prjSelectedItem) prjSelectedItem = TreeView_GetSelection(prjTreeWindow); break; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_TBPROFILE: if (HIWORD(wParam) == CBN_SELENDOK) { int i = SendMessage(hwndTbProfile, CB_GETCURSEL, 0 , 0); if (i != CB_ERR) { if (i == 0) { strcpy(currentProfileName, sysProfileName); } else { PROFILENAMELIST *pf = profileNames; while (pf && --i) pf = pf->next; if (pf) { strcpy(currentProfileName, pf->name); } } MarkChanged(workArea, TRUE); } } break; case ID_TBBUILDTYPE: if (HIWORD(wParam) == CBN_SELENDOK) { int i = SendMessage(hwndTbBuildType, CB_GETCURSEL, 0 , 0); if (i != CB_ERR) { profileDebugMode = i == 0 ? 1 : 0; MarkChanged(workArea, TRUE); } } break; case IDM_RESETPROFILECOMBOS: { HWND htemp; PROFILENAMELIST *pf; int selected,n; int count; POINT pt; pf = profileNames; selected = 0; count = 0; SendMessage(hwndTbProfile, CB_RESETCONTENT, 0, 0); SendMessage(hwndTbProfile, CB_ADDSTRING, 0, (LPARAM)sysProfileName); while (pf) { count++; if (!strcmp(pf->name,currentProfileName)) selected = count; SendMessage(hwndTbProfile, CB_ADDSTRING, 0, (LPARAM)pf->name); pf = pf->next; } SendMessage(hwndTbProfile, CB_SETCURSEL, selected, 0); SendMessage(hwndTbBuildType, CB_RESETCONTENT, 0, 0); SendMessage(hwndTbBuildType, CB_ADDSTRING, 0, (LPARAM)"Debug"); SendMessage(hwndTbBuildType, CB_ADDSTRING, 0, (LPARAM)"Release"); SendMessage(hwndTbBuildType, CB_SETCURSEL, profileDebugMode ? 0 : 1, 0); pt.x = 5; pt.y = 5; htemp = ChildWindowFromPoint(hwndTbProfile, pt); SendMessage(htemp, EM_SETREADONLY, 1, 0); htemp = ChildWindowFromPoint(hwndTbBuildType, pt); SendMessage(htemp, EM_SETREADONLY, 1, 0); EnableWindow(hwndTbProfile, TRUE); EnableWindow(hwndTbBuildType, TRUE); break; } case IDM_IMPORT_CWS: ImportProject(FALSE); break; case IDM_IMPORT_CTG: ImportProject(TRUE); break; case IDM_DOSWINDOW: { DosWindow(activeProject ? activeProject->realName : NULL, NULL, NULL, NULL, NULL); } break; case IDM_MAKEWINDOW: { char exec[MAX_PATH]; sprintf(exec, "%s\\bin\\imake.exe", szInstallPath); DosWindow(activeProject ? activeProject->realName : NULL, exec, "", "Custom Make", "Make Is Complete."); } break; case IDM_RUN: SaveWorkArea(workArea); dbgRebuildMain(wParam); break; case IDM_SETACTIVEPROJECT: ProjectSetActive(); break; case IDM_NEWFILE_P: ProjectNewFile(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_EXISTINGFILE: ProjectExistingFile(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_NEWPROJECT: ProjectNewProject(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_EXISTINGPROJECT: ProjectExistingProject(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break ; case IDM_REMOVE: ProjectRemove(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_RENAME: ProjectRename(); break; case IDM_NEWFOLDER: ProjectNewFolder(); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); break; case IDM_NEWWS: if (uState != notDebugging) { if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, "This action requires the debugger to be stopped.") != IDOK) { break; } abortDebug(); } SelectWindow(DID_PROJWND); ProjectNewWorkArea(); break; case IDM_OPENWS: if (uState != notDebugging) { if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, "This action requires the debugger to be stopped.") != IDOK) { break; } abortDebug(); } SelectWindow(DID_PROJWND); ProjectExistingWorkArea(); break; case IDM_CLOSEWS: if (making) break; if (uState != notDebugging) { if (ExtendedMessageBox("WorkArea", MB_OKCANCEL, "This action requires the debugger to be stopped.") != IDOK) { break; } abortDebug(); } CloseWorkArea(); break; case IDM_SAVEWS: SaveAllProjects(workArea, TRUE); break; case IDM_COMPILEFILEFROMTREE: { PROJECTITEM *data = GetItemInfo(prjSelectedItem); if (data && data->type == PJ_FILE) { unlink(data->outputName); Maker(data, TRUE); } } break; case IDM_COMPILEFILE: win = (HWND)SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0); if (IsWindow(win) && IsEditWindow(win)) { HTREEITEM item = FindItemByWind(win); PROJECTITEM *data = GetItemInfo(item); if (data) { unlink(data->outputName); Maker(data, TRUE); } } break; case IDM_GENMAKE: if (workArea && workArea->children) { genMakeFile(workArea); } else { ExtendedMessageBox("Makefile Generation", MB_SETFOREGROUND | MB_SYSTEMMODAL, "You need at least one project to generate a make file"); } break; case IDM_MAKE: if (HIWORD(wParam)) if (GetKeyState(VK_CONTROL) &0x80000000) SendMessage(hwnd, WM_COMMAND, IDM_COMPILEFILE, 0); else if (GetKeyState(VK_SHIFT) &0x80000000) Maker(activeProject, FALSE); else Maker(workArea, FALSE); else Maker(workArea, FALSE); break; case IDM_MAKE_RIGHTCLICK: if (HIWORD(wParam)) if (GetKeyState(VK_CONTROL) &0x80000000) SendMessage(hwnd, WM_COMMAND, IDM_COMPILEFILE, 0); else if (GetKeyState(VK_SHIFT) &0x80000000) Maker(activeProject, FALSE); else Maker(workArea, FALSE); else { if (prjSelectedItem) { PROJECTITEM *data = GetItemInfo(prjSelectedItem); if (data) { Maker(data, FALSE); break; } } Maker(workArea, FALSE); } break; case IDM_BUILDALL: Maker(workArea, TRUE); break; case IDM_BUILDALL_RIGHTCLICK: if (prjSelectedItem) { PROJECTITEM *data = GetItemInfo(prjSelectedItem); if (data) { Maker(data, TRUE); break; } } Maker(workArea, TRUE); break; case IDM_BUILDSELECTED: Maker(activeProject, FALSE); break; case IDM_STOPBUILD: StopBuild(); break; case IDM_CALCULATEDEPENDS: CalculateProjectDepends(GetItemInfo(prjSelectedItem)); break; case IDM_RUNNODEBUG: { SaveWorkArea(workArea); RunProgram(activeProject); break; } case IDM_SELECTPROFILE: SelectProfileDialog(); break; case IDM_ACTIVEPROJECTPROPERTIES: if (activeProject) prjSelectedItem = activeProject->hTreeItem; // fall through case IDM_PROJECTPROPERTIES: data = GetItemInfo(prjSelectedItem); ShowBuildProperties(data); break; case IDM_PROJECTDEPENDS: data = GetItemInfo(prjSelectedItem); EditProjectDependencies(data); break; case IDM_OPENFILES: data = GetItemInfo(prjSelectedItem); if (data) if (data->type == PJ_FILE) { if (strlen(data->realName) >= 3 && !stricmp(data->realName + strlen(data->realName) -3, ".rc")) { NavigateToResource(data); } else { strcpy(info.dwName, data->realName); strcpy(info.dwTitle, data->displayName); info.dwLineNo = - 1; info.logMRU = FALSE; info.newFile = FALSE; CreateDrawWindow(&info, TRUE); } } break; case IDM_CLOSE: SendMessage(hwnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hwnd, iMessage, wParam, lParam); } break; case WM_LBUTTONUP: if (dragging) { SetCursor(origCurs); ReleaseCapture(); dragging = FALSE; TreeView_SelectDropTarget(prjTreeWindow, NULL); if (inView && dstItem != srcItem && srcItem && dstItem) { DragTo(dstItem, srcItem); } } break; case WM_MOUSEMOVE: if (dragging) { hittest.pt.x = (long)(short)LOWORD(lParam); hittest.pt.y = (long)(short)HIWORD(lParam); dstItem = TreeView_HitTest(prjTreeWindow, &hittest); if (dstItem && dstItem != srcItem) { PROJECTITEM *srcData = GetItemInfo(srcItem); data = GetItemInfo(dstItem); if (srcData && data) { PROJECTITEM *p = data->parent; while (p) if (p == srcData) break; else p = p->parent; if (p) { if (inView) { inView = FALSE; SetCursor(noCur); TreeView_SelectDropTarget(prjTreeWindow, NULL); } break; } } if (data && (data->type == PJ_PROJ || data->type == PJ_FOLDER)) { if (!inView) { inView = TRUE; SetCursor(dragCur); } TreeView_SelectDropTarget(prjTreeWindow, dstItem); } else { if (inView) { inView = FALSE; SetCursor(noCur); TreeView_SelectDropTarget(prjTreeWindow, NULL); } } } else { if (inView) { inView = FALSE; SetCursor(noCur); TreeView_SelectDropTarget(prjTreeWindow, NULL); } } } break; case WM_SETFOCUS: PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); SetFocus(prjTreeWindow); break; case WM_CREATE: hwndProject = hwnd; GetClientRect(hwnd, &rs); treeViewSelected = 0; dragCur = LoadCursor(hInstance, "ID_DRAGCUR"); noCur = LoadCursor(hInstance, "ID_NODRAGCUR"); folderClose = LoadBitmap(hInstance, "ID_FOLDERCLOSE"); folderOpen = LoadBitmap(hInstance, "ID_FOLDEROPEN"); treeIml = ImageList_Create(16, 16, ILC_COLOR24, IL_IMAGECOUNT+2, 0); mainIml = LoadBitmap(hInstance, "ID_FILES"); ChangeBitmapColor(mainIml, 0xffffff, RetrieveSysColor(COLOR_WINDOW)); ImageList_Add(treeIml, mainIml, NULL); ilfolderClose = ImageList_Add(treeIml, folderClose, 0); ilfolderOpen = ImageList_Add(treeIml, folderOpen, 0); DeleteObject(folderClose); DeleteObject(folderOpen); DeleteObject(mainIml); prjTreeWindow = CreateWindowEx(0, sztreeDoubleBufferName, "", WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_TRACKSELECT, 0, 0, rs.right, rs.bottom, hwnd, (HMENU)ID_TREEVIEW, hInstance, NULL); TreeView_SetImageList(prjTreeWindow, treeIml, TVSIL_NORMAL); lf = systemDialogFont; projFont = CreateFontIndirect(&lf); lf.lfItalic = TRUE; italicProjFont = CreateFontIndirect(&lf); lf.lfItalic = FALSE; lf.lfWeight = FW_BOLD; boldProjFont = CreateFontIndirect(&lf); SendMessage(prjTreeWindow, WM_SETFONT, (WPARAM)boldProjFont, 0); return 0; case WM_CLOSE: SaveAllProjects(workArea, FALSE); break; case WM_DESTROY: FreeSubTree(workArea, FALSE); DestroyWindow(prjTreeWindow); DeleteObject(projFont); DeleteObject(boldProjFont); DeleteObject(italicProjFont); DestroyCursor(dragCur); DestroyCursor(noCur); hwndProject = 0; break; case WM_SIZE: MoveWindow(prjTreeWindow, 0, 0, LOWORD(lParam), HIWORD(lParam), 0); break; default: break; } return DefWindowProc(hwnd, iMessage, wParam, lParam); }
long MeasureRunProgramTime(CGraph & graph, std::string const& inName, std::string const& outName) { auto start = std::clock(); RunProgram(graph, inName, outName); return std::clock() - start; }
void CmFile::RmFolder(CStr& dir) { CleanFolder(dir); if (FolderExist(dir)) RunProgram("Cmd.exe", format("/c rmdir /s /q \"%s\"", _S(dir)), true, false); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HANDLE hEtc = INVALID_HANDLE_VALUE; BOOL bIsMassStorage = FALSE; TCHAR szProgram[MAX_PATH] = {0,}; BOOL bDispUpdate = FALSE; hEtc = CreateFile(ETC_DRIVER_NAME, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); if (INVALID_HANDLE_VALUE != hEtc) CheckWifiMacAddress(hEtc); bIsMassStorage = (1 == ufnGetCurrentClientName()) ? TRUE : FALSE; if (bIsMassStorage) { ufnChangeCurrentClient(0); // Serial_Class Sleep(1000); ufnChangeCurrentClient(1); // Mass_Storage_Class } sndPlaySound(_T("\\Windows\\Startup.wav"), SND_FILENAME | SND_ASYNC); if (FALSE == RegOpenCreateStr(OMNIBOOK_REG_KEY, APP_STARTUP_REG_STRING, szProgram, MAX_PATH, FALSE)) { RETAILMSG(1, (_T("RegOpenCreateStr(%s), Default(%s)\r\n"), APP_STARTUP_REG_STRING, APP_STARTUP_REG_DEFAULT)); _tcscpy(szProgram, APP_STARTUP_REG_DEFAULT); } if (IsProgram(szProgram)) { if (RunProgram(szProgram, NULL, 0)) { RETAILMSG(1, (_T("RunProgram(%s)\r\n"), szProgram)); bDispUpdate = TRUE; } else { RETAILMSG(1, (_T("ERROR : RunProgram(%s)\r\n"), szProgram)); } } if (FALSE == bDispUpdate) { HDC hDC = GetDC(HWND_DESKTOP); DirtyRectUpdate(hDC); InvalidateRect(HWND_DESKTOP, NULL, TRUE); ReleaseDC(HWND_DESKTOP, hDC); if (FALSE == RegOpenCreateStr(OMNIBOOK_REG_KEY, APP_UPDATE_REG_STRING, szProgram, MAX_PATH, FALSE)) { RETAILMSG(1, (_T("RegOpenCreateStr(%s), Default(%s)\r\n"), APP_UPDATE_REG_STRING, APP_UPDATE_REG_DEFAULT)); _tcscpy(szProgram, APP_UPDATE_REG_DEFAULT); } if (IsProgram(szProgram)) { if (RunProgram(szProgram, NULL, 0)) RETAILMSG(1, (_T("RunProgram(%s)\r\n"), szProgram)); else RETAILMSG(1, (_T("ERROR : RunProgram(%s)\r\n"), szProgram)); } else { RETAILMSG(1, (_T("ERROR : Not Found - %s\r\n"), szProgram)); } } if (FALSE == RegOpenCreateStr(OMNIBOOK_REG_KEY, APP_SIPSYMBOL_REG_STRING, szProgram, MAX_PATH, FALSE)) { RETAILMSG(1, (_T("RegOpenCreateStr(%s), Default(%s)\r\n"), APP_SIPSYMBOL_REG_STRING, APP_SIPSYMBOL_REG_DEFAULT)); _tcscpy(szProgram, APP_SIPSYMBOL_REG_DEFAULT); } if (IsProgram(szProgram)) { RunProgram(szProgram, NULL, 0); RETAILMSG(1, (_T("RunProgram : %s\r\n"), szProgram)); } else { RETAILMSG(1, (_T("ERROR : Not Found - %s\r\n"), szProgram)); } HDC hDC = GetDC(HWND_DESKTOP); BOOL bDirtyRect = (BOOL)ExtEscape(hDC, DRVESC_GET_DIRTYRECT, 0, NULL, 0, NULL); for (int i=0; (FALSE==bDirtyRect && i<5); i++) { Sleep(1000); bDirtyRect = (BOOL)ExtEscape(hDC, DRVESC_GET_DIRTYRECT, 0, NULL, 0, NULL); if (bIsMassStorage) bDirtyRect = DeviceIoControl(hEtc, IOCTL_IS_ATTACH_UFN, NULL, 0, NULL, 0, NULL, NULL); } if (FALSE == bDirtyRect) DirtyRectUpdate(hDC); ReleaseDC(HWND_DESKTOP, hDC); HANDLE hEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, _T("PowerManager/ReloadActivityTimeouts")); if (hEvent) { SetEvent(hEvent); CloseHandle(hEvent); RETAILMSG(0, (_T("SetEvent(PowerManager/ReloadActivityTimeouts)\r\n"))); } if (INVALID_HANDLE_VALUE != hEtc) { DeviceIoControl(hEtc, IOCTL_SET_POWER_WLAN, NULL, FALSE, NULL, 0, NULL, NULL); CloseHandle(hEtc); } return 0; }
int _tmain(int argc, _TCHAR* argv[]) { HINSTANCE hLib; FILE *theProgram; int result, i; char dummy[1024]; printf( "***********************\n" ); printf( "*** Firing Box v%03d ***\n", VERSION ); printf( "***********************\n\n" ); if( argc < 2 ) { printf( "Please specify a file name." ); return( 0 ); } theProgram = fopen( argv[1], "r" ); if( theProgram == NULL ) { printf( "File could not be opened." ); return( 0 ); } PPORT_BASE = 0; while( PPORT_BASE == 0 ) { printf( "Please select a port:\n" ); printf( "0. LPT0 (0x3bc)\n" ); printf( "1. LPT1 (0x378)\n" ); printf( "2. LPT2 (0x278)\n" ); switch( getch() ) { case '0': PPORT_BASE = LPT0_BASE; printf( "Port 0 Selected - 0x%x.\n\n", PPORT_BASE ); break; case '1': PPORT_BASE = LPT1_BASE; printf( "Port 1 Selected - 0x%x.\n\n", PPORT_BASE ); break; case '2': PPORT_BASE = LPT2_BASE; printf( "Port 2 Selected - 0x%x.\n\n", PPORT_BASE ); break; default: printf( "\n" ); fflush( stdin ); break; } } result = fscanf( theProgram, "%s%d", dummy, &SelectDelay ); if( result < 2 || result == EOF ) { printf( "Unable to determine Selection Delay." ); return( 0 ); } printf( "Selection Delay: %dms\n", SelectDelay ); result = fscanf( theProgram, "%s%d", dummy, &FireDelay ); if( result < 2 || result == EOF ) { printf( "Unable to determine Firing Delay." ); return( 0 ); } printf( "Firing Delay: %dms\n", FireDelay ); i = 0; while( (result = fscanf( theProgram, "%s%d %s%d %s%d %s%s", dummy, &theSequence[i].Socket, dummy, &theSequence[i].Queue, dummy, &theSequence[i].Delay, dummy, theSequence[i].Desc )) != EOF && i < 128 ) { if( result < 8 ) printf( "Malformed queue information, item %d.\n", i ); else if( theSequence[i].Socket < 0 || theSequence[i].Socket > 7 ) printf( "Illegal socket, item %d.\n", i ); else if( theSequence[i].Queue < 0 || theSequence[i].Queue > 15 ) printf( "Illegal queue, item %d.\n", i ); else if( theSequence[i].Delay < 0 ) printf( "Illegal delay (negative), item %d.\n", i ); else { printf( "Socket: %d ", theSequence[i].Socket ); printf( "Queue: %d ", theSequence[i].Queue ); printf( "Delay: %d ", theSequence[i].Delay ); printf( "Description: %s\n", theSequence[i].Desc ); i++; } } printf( "Program items: %d\n", i ); totalQueues = i; // Setup DLL hLib = LoadLibrary("inpout32.dll"); if (hLib == NULL) { fprintf(stderr,"LoadLibrary Failed.\n"); return -1; } inp32fp = (inpfuncPtr) GetProcAddress(hLib, "Inp32"); if (inp32fp == NULL) { fprintf(stderr,"GetProcAddress for Inp32 Failed.\n"); return -1; } oup32fp = (oupfuncPtr) GetProcAddress(hLib, "Out32"); if (oup32fp == NULL) { fprintf(stderr,"GetProcAddress for Oup32 Failed.\n"); return -1; } while( 1 ) { printf( "\n\n" ); printf( "Test (A)ll, (T)est Program, (R)un Program, (F)ire Individual, or (Q)uit.\n" ); switch( getch() ) { case 'a': case 'A': TestAllQueues(); break; case 't': case 'T': TestProgram(); break; case 'r': case 'R': RunProgram(); break; case 'f': case 'F': FireSpecificQueue(); break; case 'q': case 'Q': printf( "Quiting.\n" ); return( 0 ); } } }