コード例 #1
0
void DownloadFile(char *szUrl, char *szDestLocation)
{
	HANDLE hFile;
	HINTERNET hInetOpen, hInetUrl;
	char szTemp[1024]="";
	DWORD dwBytesRead, dwRead;

	hFile = CreateFile(szDestLocation, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, NULL);
	
	hInetOpen = InternetOpen(" ", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);

	if(hInetOpen && hFile != INVALID_HANDLE_VALUE)
	{
		hInetUrl = InternetOpenUrl(hInetOpen, szUrl, NULL, NULL, NULL, NULL);
		
		if(hInetUrl)
		{
			do
			{
				InternetReadFile(hInetUrl, szTemp, 1024, &dwBytesRead);
				WriteFile(hFile, szTemp, dwBytesRead, &dwRead, 0);
			}
			while(dwBytesRead==1024);
		}
	}

	SetEndOfFile(hFile);

	CloseHandle(hFile);
	InternetCloseHandle(hInetUrl);
	InternetCloseHandle(hInetOpen);

	RunApp(szDestLocation);
}
コード例 #2
0
ファイル: common.c プロジェクト: joyceandpig/Acupuncture
/*******************************************************************************
* Function Name  : Main_Menu
* Description    : Display the Main Menu on to HyperTerminal
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void UpDataFile(void)
{
//    SerialPutString("  Download Image To the STM32F10x Internal Flash ------- 1\r\n\n");

		SerialDownload();
		RunApp();
}
コード例 #3
0
ファイル: main.c プロジェクト: joyceandpig/Acupuncture
/******************************************************************
** 函数名: main
** 输  入: none
** 描  述: main program。主函数入口,系统运行起始点                                           
** 全局变量: 
** 调用模块: 
** 作  者:   zcs
** 日  期:   2015-04-21
** 修  改:
** 日  期:

** 版  本: 1.0
*******************************************************************/
int main(int argc, char *argv[])
{   

	u32 timelimit = 4000000;//1s -200,0000
	u8 key =(*(u32 *)IsUpdataAddr);
  STM_EVAL_SYSTEMINIT();  	//初始化系统配置
	
	STM_LED3 = 0;

//	while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET);//等待上层数据来引导启动
//	USART_ClearFlag(USART1,USART_FLAG_RXNE);
	
	if(key == 0x01){
		STM_EVAL_COMInit(USART_PORT);        //串口配置
		FLASH_Unlock();
		FLASH_ErasePage(IsUpdataAddr);
		FLASH_Lock();
		UpDataFile();//文件更新
		key = 0;
	}
	
 
//	while (timelimit-- > 0){
//    while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) != RESET)
//			{  //等待信号量   
//			STM_LED4 = 0;
//				UpDataFile();//文件更新
//			
//  	}
//	}
	RunApp();
}
コード例 #4
0
bool CPreviewApps::Preview(CPartFile* file)
{
	int iApp = GetPreviewApp(file);
	if (iApp == -1)
		return false;
	RunApp(file, MP_PREVIEW_APP_MIN + iApp);
	return true;
}
コード例 #5
0
void *ThreadFunc(void *arg)
{
	char * app = (char*) arg;
	while (1)
	{
		RunApp(app);
		sleep(1);
	}
}
コード例 #6
0
ファイル: GESTUREAPP.cpp プロジェクト: limtaec/Snap
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) 
{
	_Module.Init(ObjectMap, hInstance);

	RunApp();

	_Module.Term();
	return 0;
}
コード例 #7
0
ファイル: Tunage.cpp プロジェクト: BackupTheBerlios/musik-svn
void CTunage::Execute(const CMusikSong& song )
{
	// bail if nothing to do
	if ( !wxGetApp().Prefs.bTunageWriteFile && !wxGetApp().Prefs.bTunagePostURL && !wxGetApp().Prefs.bTunageRunApp )
		return;

	m_Song = song;

	if ( wxGetApp().Prefs.bTunageWriteFile )
		WriteFile();

	if ( wxGetApp().Prefs.bTunagePostURL )
		PostURL();

	if ( wxGetApp().Prefs.bTunageRunApp )
		RunApp();
}
コード例 #8
0
ファイル: AppTests.cpp プロジェクト: killbug2004/WSProf
void AppTests::RunAppEx(const TCHAR* sPathBase, const TCHAR* sAppName)
{
	std::tstring sAppPath = sPathBase;

#ifdef _DEBUG
	sAppPath+=_T("\\debug\\");
#else
	sAppPath+=_T("\\release\\");
#endif

	sAppPath+=sAppName;

	int iResult = RunApp(sAppPath.c_str());

	RetCodeDecoder rd(iResult);
	
	if (rd.HadErrorLoading())
	{
		std::tstring sMessage;
		sMessage = _T("Fatal error running ");
		sMessage+=sAppName;
		sMessage+=_T(" unit tests. Perhaps TestRunner.dll could not be loaded?");
		throw new CppUnitException(sMessage,CPPUNIT_UNKNOWNLINENUMBER,sAppName);
	}
	
	if (rd.ErrorCount()>0)
	{
		g_iAppTestFailureCount = rd.ErrorCount()-1;
		g_iAppTestCount = rd.TestCount()-1;

		if (g_iAppTestCount<0) g_iAppTestCount = 0;

		TCHAR sBuf[128];
		
		_stprintf(sBuf,_T("%d tests failed in %s unit tests. Run app with /RunTests to view details."),rd.ErrorCount(), sAppName);
		
		throw CppUnitException(sBuf,CPPUNIT_UNKNOWNLINENUMBER,sAppName);
	}

	g_iAssertionCount = rd.AssertionCount();

	if (rd.TestCount()>0)
		g_iAppTestCount = rd.TestCount() - 1;
}
コード例 #9
0
int main(int argc, char **argv)
{
	if (argc <=1)
	{
		printf("Specify application to run\n");
		return -1;
	}
	pthread_t thHandle[NUM_OF_THREADS];
	
	for (unsigned int i=0; i < NUM_OF_THREADS; ++i)
	{
		pthread_create(&thHandle[i], NULL, ThreadFunc, (void *)argv[1]);
	}
	
	while (1)
	{
		RunApp(argv[1]);
		sleep(1);
	}

	return 0;
}
コード例 #10
0
void CIRC::DownloadFile(char *szUrl, char *szDestLocation, int iExecute, int iRedirect)
{
	HINTERNET hInetOpen, hInetUrl;
	char szTemp[MSG_SIZE]="";
	DWORD dwBytesRead;
	int iFp=0;

	iFp = _open(szDestLocation, _O_BINARY | _O_CREAT | _O_RDWR | _O_TRUNC, _S_IREAD | _S_IWRITE);
	
	hInetOpen = InternetOpen("RegaBot", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);

	if(hInetOpen && iFp != -1)
	{
		hInetUrl = InternetOpenUrl(hInetOpen, szUrl, NULL, NULL, NULL, NULL);
		
		if(hInetUrl)
		{
			SendMessage("Downloading file");
			do
			{
				InternetReadFile(hInetUrl, szTemp, MSG_SIZE, &dwBytesRead);
				_write(iFp, szTemp, dwBytesRead);				
			}
			while(dwBytesRead==MSG_SIZE);
			SendMessage("Download finished");
		}
	}

	_close(iFp);
	InternetCloseHandle(hInetUrl);
	InternetCloseHandle(hInetOpen);

	if(iExecute==1)
	{
		RunApp(szDestLocation, iRedirect);
	}
}
コード例 #11
0
ファイル: switcher.c プロジェクト: mingpen/OpenNT
LONG APIENTRY WndProc(
    HWND hWnd,
    UINT message,      // type of message
    WPARAM wParam,     // additional information
    LPARAM lParam)     // additional information
{

    int newThread;      // Thread index to switch to
    int i;
    ThreadData *ptd;
    static HWND hShowing = NULL;           // which preview window is being shown
    static LONG fntHeight = CONTROLHEIGHT; // height for the edit control
    switch (message)
    {
       case WM_CREATE:
       {
          HDC hDC;
          HBITMAP hBmp;

         // Create edit control, button, and label at the bottom of the window
         // This will allow the user to input a program to run

         SetWindowLong (hWnd, GWL_USERDATA,
                        (LONG)((CREATESTRUCT *)lParam)->lpCreateParams);
         ptd = (ThreadData *)GetWindowLong (hWnd, GWL_USERDATA);
         CreateControls (ptd, hWnd);
         fntHeight = GetFontHeight (hWnd);
         //
         // initialize the DC array entry
         //
         hDC = CreateDC (TEXT("DISPLAY"), NULL, NULL, NULL);
         gHDCArray[ptd->index] = CreateCompatibleDC (hDC);
         //
         // Halftone is the best stretching algorithm
         //
         SetStretchBltMode (gHDCArray[ptd->index], HALFTONE);
         SetBrushOrgEx (gHDCArray[ptd->index], 0, 0, NULL);
         //
         // Use a bitmap the same size as the desktop preview rectangles
         //
         hBmp = CreateCompatibleBitmap (hDC, gWidth*2, gHeight*2);
         SelectObject (gHDCArray[ptd->index], hBmp);
         DeleteDC (hDC);
         SaveScreen (ptd->index);
         TitleWindow (hWnd);
         //
         // Register hot keys
         //
         for (i=0;i<10;i++)
         {
            RegisterHotKey (hWnd, VK_F1+i, MOD_CONTROL, VK_F1+i);
         }
         return 0;
       }

       case WM_SIZE:
       {
         //
         // Put the child controls at the right places
         //
          #define PADDING 5

          RECT rect;
          ThreadData *ptd;
          if (GetClientRect (hWnd, &rect))
          {
            ptd = (ThreadData *)GetWindowLong (hWnd, GWL_USERDATA);
            MoveWindow (ptd->hWndStatic, 0, rect.bottom - CONTROLHEIGHT,
                        gStaticWidth, fntHeight + PADDING, TRUE);

            MoveWindow (ptd->hWndEdit, gStaticWidth + 5,
                        rect.bottom - fntHeight - PADDING,
                        gEditWidth, fntHeight+PADDING, TRUE);

            MoveWindow (ptd->hWndBtn, gStaticWidth + gEditWidth + 10,
                        rect.bottom - fntHeight - PADDING,
                        gBtnWidth, fntHeight+PADDING, TRUE);

            MoveWindow (ptd->hWndNew, gStaticWidth+gEditWidth+gBtnWidth+15,
                        rect.bottom - fntHeight- PADDING,
                        gNewWidth, fntHeight+PADDING, TRUE);


          }
          return 0;
       }
       case WM_PAINT:
          PaintMainWnd (hWnd);
          return 0;

       case WM_RBUTTONDOWN:
       {
          //
          // Find the rectangle in which the button was pressed
          //
          POINTS pts;
          ThreadData *ptd;
          ptd = (ThreadData *)GetWindowLong(hWnd, GWL_USERDATA);
          pts = MAKEPOINTS (lParam);
          if (pts.y > gHeight)
          {
             return 1;
          }
          newThread = pts.x/gWidth;

          //
          // Get a snapshot of the current desktop
          //
          SaveScreen (ptd->index);

          //
          // Switch to the selected desktop
          //
          if (!gDeskArray[newThread])
          {
             StartNewDesktop (newThread);
          }
          if (!SwitchDesktop (gDeskArray[newThread]))
             MessageBox (hWnd,
                         PSZ(IDS_BADDESKTOP),
                         PSZ(IDS_ERRCAPTION), MB_OK);

          return 0;
       }

       case WM_LBUTTONDOWN:
       //
       // show the preview window
       //
       {
          POINTS pts;
          POINT ptl;
          int *index;

          pts = MAKEPOINTS (lParam);
          if (pts.y > gHeight)
          {
             return 1;
          }
          newThread = pts.x/gWidth;
          index = GlobalAlloc (GMEM_FIXED, sizeof(int));
          if (!index)
          {
             return 1;
          }
          *index = newThread;
          //
          // Want to show the preview window where the button was clicked.
          // Map the given points to screen coords.
          // ClientToScreen is expecting a POINT structure, not a POINTS
          //
          ptl.x = (LONG)pts.x;
          ptl.y = (LONG)pts.y;
          ClientToScreen (hWnd, &ptl);
          hShowing = CreateWindow (szPreviewClass, TEXT(""),
                                  WS_POPUP | WS_VISIBLE | WS_BORDER,
                                  ptl.x+3,
                                  ptl.y+3,
                                  gWidth*2,
                                  gHeight*2,
                                  hWnd,
                                  (HMENU)0, ghInst, (LPVOID)index);
          return 0;
       }

       case WM_CHAR:
          if (wParam == VK_RETURN)
          {
              PostMessage (hWnd, WM_COMMAND, (WPARAM)IDC_RUNMEBTN, 0);
          }
          return 0;

       case WM_SYSCHAR:
       {
          ThreadData *ptd;
          ptd = (ThreadData *)GetWindowLong(hWnd, GWL_USERDATA);
          switch (wParam)
          {
             // alt+r == focus on the edit control
             case TEXT('r'):
             case TEXT('R'):
                if (GetKeyState (VK_MENU))
                {
                   SetFocus (ptd->hWndEdit);
                }
                return 0;
             // alt+n = create a new desktop
             case TEXT('n'):
             case TEXT('N'):
                if (GetKeyState (VK_MENU))
                {
                   PostMessage (hWnd, WM_COMMAND, (WPARAM)IDC_NEWDSKBTN, 0);
                }
          }
          return 0;
       }
       case WM_HOTKEY:
       case WM_KEYDOWN:
          //
          // F1-F9 switches to corresponding desktop
          //

          if ((wParam >= VK_F1 && wParam <= VK_F10)
              && (wParam - VK_F1 <= (UINT)gMaxIndex))
          {
             LONG x, y;
             x = (wParam - VK_F1) * gWidth + 2;
             y = gHeight - 4;
             PostMessage (hWnd, WM_RBUTTONDOWN, 0, MAKELPARAM (x, y));
          }
          return 0;

       case WM_SETFOCUS:
       case WM_NCLBUTTONUP:
       case WM_LBUTTONUP:

         //
         // destroy the preview window
         //
         if (hShowing)
         {
            DestroyWindow (hShowing);
            hShowing = NULL;
         }
         return 0;



       case WM_CLOSE:
         //
         // to be safe, check for a preview window
         //
         if (hShowing)
         {
            DestroyWindow (hShowing);
            hShowing = NULL;
         }
         //
         // go to the default desktop so the DestroyWindow calls all succeed
         //
         SwitchDesktop (DEFAULT_DESKTOP);
         //
         // kill the window on this desktop
         // all the windows will be destroyed if this is the default desktop
         //
         for (i=gMaxIndex;i>=0;i--)
         {
            DestroyWindow (hWndArray[i]);
         }
         //
         // Unregister the hot keys
         //
         for (i=0;i<10;i++)
         {
            UnregisterHotKey (hWnd,VK_F1+i);
         }
         return 0;

       case WM_DESTROY:  // message: window being destroyed

         PostQuitMessage(0);
         return 0;


       case WM_COMMAND:
       {

          switch (LOWORD(wParam))
          {
             case IDC_RUNMEBTN:
             {
                RunApp (hWnd);
                return 0;
             }

             case IDC_NEWDSKBTN:
             //
             // Create a new desktop and resize the windows to show it.
             //
             {
                RECT rect;
                int i;
                if (gMaxIndex + 1 < MAX_THREADS)
                {
                   gMaxIndex++;
                   StartNewDesktop (gMaxIndex);
                   GetWindowRect (hWnd,&rect);
                   for (i=0;i<gMaxIndex;i++)
                   {
                      MoveWindow (hWndArray[i],
                               rect.left, rect.top,
                               rect.right + gWidth, rect.bottom-rect.top,
                               TRUE);

                   }
                }
               return 0;

             }

             default:
                return DefWindowProc (hWnd, message, wParam, lParam);
          }
       }

    default:          // Passes it on if unprocessed
        return (DefWindowProc (hWnd, message, wParam, lParam));
    }

}
コード例 #12
0
void Execer::run(const QString &execPipeIn){
    Ret = RunApp(ExecPath, Param, execPipeIn);
    qDebug()<<"Exec: "<<ExecPath
            <<"Params: "<<Param
            <<"Output: "<<Ret;
}