示例#1
2
BOOL CIperfThread::InitInstance()
{
    // TODO:  スレッドごとの初期化をここで実行します。
    HANDLE hOldIn = GetStdHandle(STD_INPUT_HANDLE);
    HANDLE hOldOut = GetStdHandle(STD_OUTPUT_HANDLE);
    HANDLE hOldErr = GetStdHandle(STD_ERROR_HANDLE);

    STARTUPINFOA si;
    memset(&si,0,sizeof(STARTUPINFO));
    si.cb = sizeof(STARTUPINFO);
    si.dwFlags |= STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_HIDE;


    m_uniqid = mkhash(m_CmdLine, m_uniqid) ;
    m_uniqid += (WORD)m_nThreadID;
    m_uniqid += (WORD)m_nThreadID >> 4;

    FreeConsole();
    AllocConsole();

    CreateIperfPipe();

    if(CreateProcess(NULL, m_CmdLine, NULL, NULL, TRUE, 0,
        NULL, NULL, &si, &m_ProcessInfo) == FALSE ) {
        return FALSE;
    }

    EnumWindows(WindowHidden, (LPARAM)(PROCESS_INFORMATION *)&m_ProcessInfo);
    WaitForInputIdle(m_ProcessInfo.hProcess, INFINITE);
    SetStdHandle(STD_OUTPUT_HANDLE,hOldOut);
    SetStdHandle(STD_INPUT_HANDLE,hOldIn);
    SetStdHandle(STD_ERROR_HANDLE,hOldErr);
    EnumWindows(WindowHidden, (LPARAM)(PROCESS_INFORMATION *)&m_ProcessInfo);
    return TRUE;
}
示例#2
0
void MainWindow::updateWinList(void)
{
    model->removeRows(0, model->rowCount());
    witems.clear();
    EnumWindows(EnumWindowsProc, (LPARAM)this);
    for(int i = 0; i < witems.size(); i++) {
        model->insertRow(i);
        model->setData(model->index(i, 0), QString::number(witems[i].num));
        model->setData(model->index(i, 1), witems[i].title);
        model->setData(model->index(i, 2), witems[i].exec);
    }
    ui->winView->setCurrentIndex(proxy->index(0,0));
    ui->noteText->clear();
    ui->noteText->append("QuickWin " + gVerStr + " found " + QString::number(witems.size()) + " windows.");
}
BOOL InjectEjectToWindowClassA(LPCSTR lpClassName, LPCSTR lpLibPath, LPVOID lpModule, BOOL inject, BOOL mm)
{
	struct INJ_DATA injdata = {2, lpClassName, lpLibPath, lpModule, inject, mm};

	if(!EnumWindows((WNDENUMPROC)&EWP_DirectInject, (LPARAM)&injdata))
	{
		DWORD dwLastError = GetLastError();
		if(dwLastError)
		{
			PRINT_ERROR_MSGA("EnumWindows failed.");
			return FALSE;
		}
	}

	return TRUE;
}
示例#4
0
文件: GlassCMD.cpp 项目: chenwp/shuax
void StartGlassCMD()
{
	PROCESSENTRY32 pe32;
	HANDLE hProcessSnap = NULL;
	pe32.dwSize = sizeof(PROCESSENTRY32);
	hProcessSnap = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
	for (Process32First (hProcessSnap, &pe32); Process32Next (hProcessSnap, &pe32);)
	{
		if (stricmp(pe32.szExeFile, "cmd.exe") == 0)
		{
			EnumWindows((WNDENUMPROC)EnumWndProc, pe32.th32ProcessID);
		}
	}
	CloseHandle(hProcessSnap);

}
示例#5
0
BOOL CWordPadApp::IsDocOpen(LPCTSTR lpszFileName)
{
	if (lpszFileName[0] == NULL)
		return FALSE;
	TCHAR szPath[_MAX_PATH];
	AfxFullPath(szPath, lpszFileName);
	ATOM atom = GlobalAddAtom(szPath);
	ASSERT(atom != NULL);
	if (atom == NULL)
		return FALSE;
	EnumWindows(StaticEnumProc, (LPARAM)&atom);
	if (atom == NULL)
		return TRUE;
	DeleteAtom(atom);
	return FALSE;
}
示例#6
0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int showCmd) {

	EnumWindows(callback, 0);

	SetForegroundWindow(hTarget);
	if (!IeFlg) {
		keybd_event(VK_BROWSER_REFRESH, 0, 0, 0);
	} else {
		keybd_event(VK_F5, 0, 0, 0);
	}

	SetForegroundWindow(hMe[0]);
	SetWindowPos(hMe[0], HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);

	return 0;
}
示例#7
0
static void virgo_update(Virgo *v)
{
	int i, e;
	Windows *desk;
	HWND hwnd;
	for(i=0; i<NUM_DESKTOPS; i++) {
		desk = &(v->desktops[i]);
		for(e=0; e<desk->count; e++) {
			hwnd = desk->windows[e];
			if(!GetWindowThreadProcessId(desk->windows[e], NULL)) {
				windows_del(desk, hwnd);
			}
		}
	}
	EnumWindows((WNDENUMPROC)&enum_func, (LPARAM)v);
}
示例#8
0
DWORD WINAPI setUserNamePasswordThread(LPVOID lpDummy)
{
	DWORD dwPid = (DWORD)lpDummy;
	HANDLE mutex = CreateMutex(NULL, TRUE, _T("setUserNamePasswordMutex"));

	// Check double entrance
	if(GetLastError() == ERROR_ALREADY_EXISTS)
		return 0;

	WaitForSingleObject(SkypeReady, 5000);
	EnumWindows (EnumWindowsProc, dwPid);

	ReleaseMutex(mutex);
	CloseHandle(mutex);
	return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
///                                                                                   //
/// WindowMonitorThreadProc(LPVOID arg);                                                    //            
///                                                                                   //
////////////////////////////////////////////////////////////////////////////////////////
static DWORD WINAPI WindowMonitorThreadProc(LPVOID arg) 
{
 MSG         msg ; 
 _tsetlocale(LC_CTYPE, _T(""));
 MSG_DISPLAY_HOOK = RegisterWindowMessage(DISPLAY_HOOK_MSG);
 if (EnumWindows(EnumWindowsProc,NULL)==FALSE)
 {
  printf("Could not save all previously opened windows\n");
 }
 HookHiddenWindow=AllocateWindow(NULL,WndProc);
 PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
 
 if (HookHiddenWindow==NULL)
   {
    printf("Can't allocate window\n");
	return(0);
   }
   if (HookDisplayFptr(HookHiddenWindow->WindowHandle))
   {
    BOOL bRet;
	printf("Display Hooked\n");
	fflush(stdout);
	SetEvent(ThreadReady);
	SetTimer(HookHiddenWindow->WindowHandle,0xBEEF,1000,(TIMERPROC) NULL);    
    while (1)
          { 
		   bRet=GetMessage (&msg, NULL, 0, 0);
		   if ((bRet != -1) && (bRet!=0))
		   {
            TranslateMessage (&msg) ; 
            DispatchMessage (&msg) ;
		   }
		   else if ((bRet==0)&&(msg.wParam==0xDEADBEEF)) break; 
          } 
	KillTimer(HookHiddenWindow->WindowHandle,0xBEEF);
	if (UnhookDisplayFptr(HookHiddenWindow->WindowHandle))
	 {
      printf("Display Unhooked\n");
	  fflush(stdout);
	 }

   FreeWindow(HookHiddenWindow);
   DeleteAllWindows();
  }
  else  SetEvent(ThreadReady); // FIX ME should use timeout
	return 0;
}
// Hook procedure for WH_GETMESSAGE hook type.
//
// This function is more or less a combination of MSDN KB articles
// Q187988 and Q216503. See MSDN for additional details
LRESULT CALLBACK CDialogMessageHook::GetMessageProc(int nCode, 
                                 WPARAM wParam, LPARAM lParam)
{
    // If this is a keystrokes message, pass it to IsDialogMessage for tab
    // and accelerator processing
    LPMSG lpMsg = (LPMSG) lParam;

    // check if there is a menu active
    HWND hMenuWnd = NULL;
    EnumWindows(MyEnumProc, (LPARAM)&hMenuWnd);

    if (hMenuWnd == NULL &&
        (nCode >= 0) &&
        PM_REMOVE == wParam &&
        (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST))
    {
        HWND hWnd, hActiveWindow = GetActiveWindow();
        THWNDCollection::iterator it = m_aWindows.begin();

        // check each window we manage to see if the message is meant for them
        while (it != m_aWindows.end())
        {
            hWnd = *it;

            if (::IsWindow(hWnd) &&
                ::IsDialogMessage(hWnd, lpMsg))
            {
                // The value returned from this hookproc is ignored, and it cannot
                // be used to tell Windows the message has been handled. To avoid
                // further processing, convert the message to WM_NULL before
                // returning.
                lpMsg->hwnd = NULL;
                lpMsg->message = WM_NULL;
                lpMsg->lParam = 0L;
                lpMsg->wParam = 0;

                break;
            }

            it++;
        }
    }

    // Passes the hook information to the next hook procedure in
    // the current hook chain.
    return ::CallNextHookEx(m_hHook, nCode, wParam, lParam);
}
示例#11
0
void LiteProcess::terminate()
{
    if (m_useCtrlC) {
        Q_PID processId = this->pid();
#ifdef Q_OS_WIN
        if (processId) {
            EnumWindows(sendShutDownMessageToAllWindowsOfProcess_enumWnd, processId->dwProcessId);
        }
#else
        if (processId > 0) {
            ::kill(processId,SIGINT);
        }
#endif
    } else {
        QProcess::terminate();
    }
}
示例#12
0
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
	int argc;
	LPTSTR *argv = CommandLineToArgvW(pCmdLine, &argc);

	TCHAR path[MAX_PATH];
	GetModuleFileName(NULL, path, MAX_PATH);
	auto length = wcslen(path);
	if (!wmemcmp(argv[0], path, length))
	{
		MessageBox(NULL, TEXT("This app is designed to start another app."), TEXT("Error"), MB_OK);
		return 1;
	}

	STARTUPINFO si = { 0 };
	si.cb = sizeof(STARTUPINFO);
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_HIDE;

	PROCESS_INFORMATION pi = { 0 };

	if (!CreateProcess(argv[0], NULL, NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi))
	{
		return 2;
	}

	while (!g_hWnd)
	{
		EnumWindows(EnumWindowsProc, pi.dwProcessId);
	}

	auto hWnd = g_hWnd;
	centerWindow(hWnd);
	SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);

	float percentage = 1;
	if (argc >= 2)
	{
		swscanf(argv[1], L"%f", &percentage);
	}
	SetLayeredWindowAttributes(hWnd, 0, static_cast<BYTE>(255 * percentage), LWA_ALPHA);
	SetForegroundWindow(hWnd);
	ShowWindow(hWnd, SW_SHOW);

	return 0;
}
示例#13
0
WindowBitmap* WindowBitmap::getWindowBitmap(const std::string& process, bool directx)
{
   DWORD processID = -1;
   HWndProcess hWndProcess;
   WindowBitmap* windowBitmap = NULL;

   if( (processID = getProcessIDFromName(process)) == -1 ){
      return NULL;
   }

   hWndProcess.processID = processID;
   if( false == EnumWindows(matchProcessWindowEnumProc, (LPARAM)&hWndProcess) ){
      return new WindowBitmap(hWndProcess.hWnd, directx);
   }

   return NULL;
}
示例#14
0
int winapi_EnumWindows(lua_State* L)
{
  LUASTACK_SET(L);

  if (lua_isfunction(L, 2))
  {
    EnumWindows(EnumProc, (LPARAM)L);
  }
  else
  {
    const char *msg = lua_pushfstring(L, "function expected but got %s", luaL_typename(L, 2));
    luaL_argerror(L, 2, msg);
  }

  LUASTACK_CLEAN(L, 0);
  return 0;
}
示例#15
0
文件: main.c 项目: WizardVan/Walker
void main()
{
    HANDLE hwFind;
    EnumWindows((WNDENUMPROC)EnumWindowsProc, 0);
    hwFind = FindWindow(TEXT("Window"), TEXT("Cheat Engine 6.4"));
    if (hwFind)
        ExitProcess(0);
    hwFind = FindWindow(TEXT("TfMain"),NULL);
    if (hwFind)
    {
        hwFind = FindWindow(TEXT("TApplication"), NULL);
        if (hwFind)
            ExitProcess(0);
    }

    getchar();
}
示例#16
0
 /// minimize/restore all windows on the desktop
void Desktops::ToggleMinimize()
{
	list<MinimizeStruct>& minimized = (*this)[_current_desktop]._minimized;

	if (minimized.empty()) {
		EnumWindows(MinimizeDesktopEnumFct, (LPARAM)&minimized);
	} else {
		const list<MinimizeStruct>& cminimized = minimized;
		for(list<MinimizeStruct>::const_reverse_iterator it=cminimized.rbegin(); 
															it!=cminimized.rend(); ++it) {
			ShowWindowAsync(it->first, it->second&WS_MAXIMIZE? SW_MAXIMIZE: SW_RESTORE);
			Sleep(20);
		}

		minimized.clear();
	}
}
示例#17
0
bool CEnumWindowInfo::Enum(bool ShowAllWind,WCHAR *WinHederName,WCHAR *ProccessName,WCHAR*ClassName )
{

	lstrcpy(m_ProccessName,ProccessName);
	lstrcpy(m_WinHederName,WinHederName);
	lstrcpy(m_ClassName,ClassName);

	m_bShowAllWind=ShowAllWind;
	WIN_INFO buffer;
	ZeroMemory( &buffer, sizeof(buffer) );
	buffer.id = 0;
	lstrcpy( buffer.classname, L"Desktop" );
	lstrcpy( buffer.title, L"Desktop" );
	Add( &buffer );

	return !!EnumWindows( CheckWindow, (LPARAM)this );
}
示例#18
0
BOOL CConfigDialog::OnInitDialog()
{
	CDialog::OnInitDialog();
	DoSetButtonSkin();

	CMemReader& reader = CMemReader::getMemReader();
	

	addrFps = CMemUtil::getMemUtil().GetMemIntValue(CTibiaItem::getValueForConst("addrFps"));

	EnumWindows(EnumWindowsProc, CMemUtil::getMemUtil().getGlobalProcessId());

	SetTimer(1000, 500, NULL);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#19
0
DllExport BOOL UnSetHooks(DWORD thread_id)
{

	BOOL unHooked = TRUE;
	
	// Remove the extra property value from all local windows
	EnumWindows((WNDENUMPROC) &KillPropsProc, NULL);

	// Stop the keyboard & mouse hooks
	unHooked = unHooked && SetKeyboardFilterHook(FALSE);
	unHooked = unHooked && SetMouseFilterHook(FALSE);

	// Is the window handle valid?
	if (thread_id != vnc_thread_id)
		return FALSE;

	// Unhook the procs
	if (hCallWndHook != NULL)
	{
		unHooked = unHooked && UnhookWindowsHookEx(hCallWndHook);
		hCallWndHook = NULL;
	}

	if (hGetMsgHook != NULL)
	{
		unHooked = unHooked && UnhookWindowsHookEx(hGetMsgHook);
		hGetMsgHook = NULL;
	}

	if (hDialogMsgHook != NULL)
	{
		unHooked = unHooked && UnhookWindowsHookEx(hDialogMsgHook);
		hDialogMsgHook = NULL;
	}

	// If we managed to unhook then reset
	if (unHooked)
	{
		vnc_thread_id = 0;
		HookMaster = FALSE;
	}

	return unHooked;

}
示例#20
0
//void ThreadWatchdog()
DWORD WINAPI ThreadWatchdog(LPVOID lpParameter)
{
  for (;;)  // always do this
  {
    FILETIME currentFileTime;
    // run once
    static ULARGE_INTEGER lastFileTime = (GetSystemTimeAsFileTime(&currentFileTime), make_ularge(currentFileTime) );

    //std::this_thread::sleep_for( std::chrono::milliseconds(1000) );
    Sleep(5000);
    
    // Get the current system time
    GetSystemTimeAsFileTime(&currentFileTime);
    ULARGE_INTEGER curTime = make_ularge(currentFileTime);

    // Debug
    gTimeDiff.QuadPart = curTime.QuadPart - lastFileTime.QuadPart;
    //MessageBox(nullptr, std::to_string(gTimeDiff.QuadPart).c_str(), "Process", MB_OK);
    
    // If a window is not responding
    bool notResponding = EnumWindows(&EnumWindowsProc, 0) == FALSE && GetLastError() == WATCHDOG_ERR;
    
    // Iterate threads and check their time metrics
    Thread::lock_mutex();
    for ( auto &it : Thread::threadMap )
    {
      if ( it.second.checkCPU(notResponding) )
      {
        //  1. Pause the thread
        //  2. Retrieve its context
        //  3. Skip over next "jump if.."
        //  4. Set the new context
        //  5. Resume the thread
      }

    }
    Thread::unlock_mutex();
    
    // Save last system time
    GetSystemTimeAsFileTime(&currentFileTime);
    lastFileTime = make_ularge(currentFileTime);

  }
  return 0;
}
示例#21
0
文件: main.cpp 项目: mayhem/freeamp
void SendCommandLineToHiddenWindow()
{
    HWND hwnd = NULL;

    // we give it five attempts and then give up
    for(uint32 count = 0; count < 5; count++)
    {
        // find currently running FreeAmp player
        EnumWindows(EnumWndProc, (LPARAM)&hwnd);

        if(hwnd)
        {
            COPYDATASTRUCT data;

            if(__argc > 1)
            {
                char* filelist = NULL;
                size_t length = 0;

                for(int32 i = 1; i < __argc; i++)
                {
                    int32 argLength = strlen(__argv[i]) + 1;
                
                    filelist = (char*)realloc(filelist, length + argLength);

                    strcpy(filelist + length, __argv[i]);

                    length += argLength;
                }

                data.dwData = __argc - 1;
                data.cbData = length;
                data.lpData = filelist;

                SendMessage(hwnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&data);

                free(filelist);
            }

            break;
        }

        Sleep(500);
    }
}
示例#22
0
void main( int argc, char *argv[] )
{
    SECURITY_ATTRIBUTES attr;

    argc=argc;argv=argv;
#if 0
    if( argc > 1 && (argv[1][0] == 'q' || argv[1][0] == 'Q') ) {
        h = CreateFile( PREFIX DEFAULT_NAME, GENERIC_WRITE, 0,
                NULL, OPEN_EXISTING, 0, NULL );
        if( h != INVALID_HANDLE_VALUE ) {
            done = LNK_SHUTDOWN;
            WriteFile( h, &done, sizeof( done ), &sent, NULL );
            CloseHandle( h );
        }
        exit( 0 );
    }
#endif
    SemReadUp = CreateSemaphore( NULL, 0, 1, READUP_NAME );
    SemReadDone = CreateSemaphore( NULL, 0, 1, READDONE_NAME );
    SemWritten = CreateSemaphore( NULL, 0, 1, WRITTEN_NAME );
    MemHdl = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 1024, SHARED_MEM_NAME  );
    SharedMem = MapViewOfFile( MemHdl, FILE_MAP_WRITE, 0, 0, 0 );
    CmdProc = getenv( "ComSpec" );
    if( CmdProc == NULL ) {
        fprintf( stderr, "Unable to find command processor\n" );
        exit( 1 );
    }
    SetConsoleCtrlHandler( NULL, FALSE );
    SetConsoleCtrlHandler( Ignore, TRUE );
    //NYI: need to accept name for link pipe
    attr.nLength = sizeof( attr );
    attr.lpSecurityDescriptor = NULL;
    attr.bInheritHandle = TRUE;
    NulHdl = CreateFile( "NUL", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, &attr, OPEN_EXISTING, 0, NULL );
    if( NulHdl == INVALID_HANDLE_VALUE ) {
        fprintf( stderr, "Unable to open NUL device\n" );
        exit( 1 );
    }
    EnumWindows( HideWindows , 0 );

    Say(( "LNK_UP\n" ));
    for( ;; ) {
        ProcessConnection();
    }
}
示例#23
0
文件: display.c 项目: Bouke/Pillow
PyObject*
PyImaging_ListWindowsWin32(PyObject* self, PyObject* args)
{
    PyObject* window_list;
    
    window_list = PyList_New(0);
    if (!window_list)
        return NULL;

    EnumWindows(list_windows_callback, (LPARAM) window_list);

    if (PyErr_Occurred()) {
        Py_DECREF(window_list);
        return NULL;
    }

    return window_list;
}
示例#24
0
Bool
winRedrawScreenShadowGDI (ScreenPtr pScreen)
{
    winScreenPriv(pScreen);
    winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;

    /* Redraw the whole window, to take account for the new colors */
    BitBlt (pScreenPriv->hdcScreen,
            0, 0,
            pScreenInfo->dwWidth, pScreenInfo->dwHeight,
            pScreenPriv->hdcShadow,
            0, 0,
            SRCCOPY);

    /* Redraw all windows */
    if (pScreenInfo->fMultiWindow) EnumWindows(winRedrawAllProcShadowGDI, 0);
    return TRUE;
}
示例#25
0
BOOL CScreenCapture::FindWindows(DWORD dwProcessId, BOOL bAllProcessWindows, std::vector<WindowInfo>* paWindows)
{
    FindWindowData fwd;
    fwd.bAllProcessWindows = bAllProcessWindows;
    fwd.dwProcessId = dwProcessId;
    fwd.paWindows = paWindows;
    EnumWindows(EnumWndProc, (LPARAM)&fwd);

    if(!bAllProcessWindows) 
    {    
        // Find only the main window
        // The main window should have caption, system menu and WS_EX_APPWINDOW style.  
        WindowInfo MainWnd;
        BOOL bMainWndFound = FALSE;

        size_t i;
        for(i=0; i<paWindows->size(); i++)
        {
            if(((*paWindows)[i].dwExStyle&WS_EX_APPWINDOW) && 
                ((*paWindows)[i].dwStyle&WS_CAPTION) && 
                ((*paWindows)[i].dwStyle&WS_SYSMENU))
            {      
                // Match!
                bMainWndFound = TRUE;
                MainWnd = (*paWindows)[i];
                break;
            }
        }

        if(!bMainWndFound && paWindows->size()>0)
        {
            MainWnd = (*paWindows)[0];
            bMainWndFound = TRUE;
        }

        if(bMainWndFound)
        {
            paWindows->clear();
            paWindows->push_back(MainWnd);
        }
    }

    return TRUE;
}
示例#26
0
bool ArchHooks_Win32::CheckForMultipleInstances(int argc, char* argv[])
{
	if( !g_bIsMultipleInstance )
		return false;

	/* Search for the existing window.  Prefer to use the class name, which is less likely to
	 * have a false match, and will match the gameplay window.  If that fails, try the window
	 * name, which should match the loading window. */
	HWND hWnd = FindWindow( PRODUCT_ID, NULL );
	if( hWnd == NULL )
		hWnd = FindWindow( NULL, PRODUCT_ID );

	if( hWnd != NULL )
	{
		/* If the application has a model dialog box open, we want to be sure to give focus to it,
		 * not the main window. */
		CallbackData data;
		data.hParent = hWnd;
		data.hResult = NULL;
		EnumWindows( GetEnabledPopup, (LPARAM) &data );

		if( data.hResult != NULL )
			SetForegroundWindow( data.hResult );
		else
			SetForegroundWindow( hWnd );

		// Send the command line to the existing window.
		vector<RString> vsArgs;
		for( int i=0; i<argc; i++ )
			vsArgs.push_back( argv[i] );
		RString sAllArgs = join("|", vsArgs);
		COPYDATASTRUCT cds;
		cds.dwData = 0;
		cds.cbData = sAllArgs.size();
		cds.lpData = (void*)sAllArgs.data();
		SendMessage( 
			(HWND)hWnd, // HWND hWnd = handle of destination window
			WM_COPYDATA,
			(WPARAM)NULL, // HANDLE OF SENDING WINDOW
			(LPARAM)&cds ); // 2nd msg parameter = pointer to COPYDATASTRUCT
	}

	return true;
}
示例#27
0
文件: ps.c 项目: cftyngit/nctuns
DWORD NTLister(void) {
	
	DWORD procs[200],dummy,ignore;
	HANDLE hproc;
	HMODULE hmod;
	unsigned int i;
	

//	if (processlist)
//		p_free(processlist);

	if (!enum_processes(procs,sizeof(procs),&dummy) ) {
		return 0;
	}

	dummy = dummy/sizeof(DWORD); // number of entries filled

	processlist = heap_alloc(dummy*sizeof(pslist));
	if (!processlist){
		return 0;
	}

	for(i=0 ; i< dummy;i++) {
		processlist[i].pid = procs[i];
		processlist[i].title[0] = 0;
		hproc = OpenProcess(PROCESS_QUERY_INFORMATION |PROCESS_VM_READ,
							FALSE,procs[i]);
		if (hproc) {
			if (enum_process_modules(hproc,&hmod,sizeof(hmod),&ignore)) {
				GetModuleBaseNameA(hproc,hmod, processlist[i].exename,MAX_PATH);
			}
			else
				lstrcpy(processlist[i].exename,"(unknown)");
			CloseHandle(hproc);
		}
		else
			lstrcpy(processlist[i].exename,"(unknown)");
		
	}
	if (g_dowindows) {
		EnumWindows(enum_wincb,(LPARAM)dummy);
	}
	return dummy;
}
示例#28
0
void pdvstEditor::idle()
{

       // JYG :: masquer la fenêtre GUI créée par hôte VST pour laisser puredata le faire
  //  SetWindowPos((HWND)systemWindow,HWND_TOPMOST,-300,-300,0,0,SWP_NOSIZE);  // déplacer la fenetre
  //  SetWindowPos((HWND)systemWindow,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW); //masquer la fenêtre
  //  systemWindowHidden=true;
  // JYG
    if (((pdvst *)this->effect)->guiNameUpdated)
        if (editWindow)//&&!pdGuiWindow)
        {
            HWND tref=NULL;
            parms.ref = &tref;
            strcpy(parms.s,(char*)((pdvst *)this->effect)->guiName);
            parms.exact = false;
            EnumWindows(enumwnd,(LPARAM)&parms);
            pdGuiWindow = tref;

           // pdGuiWindow=FindWindow(NULL,"Pd_Gain(gui).pd  - C:/Program Files (x86)/Ableton/Live 8.0.4/Program/pdvst");
           //  pdGuiWindow=FindWindow(NULL,(char*)((pdvst *)this->effect)->guiName);
            if (pdGuiWindow)
            {
                if(SetParent(pdGuiWindow,(HWND)editWindow))//systemWindow))
                {
                    ((pdvst *)this->effect)->guiNameUpdated=0;
                    //Remove WS_POPUP style and add WS_CHILD style
                    DWORD style = GetWindowLong(pdGuiWindow,GWL_STYLE);
                    // style = style & ~(WS_POPUPWINDOW);
                    style = style & ~(WS_POPUP);
                    style = style & ~(WS_CHILD);    // WS_CHILD Crashes tcltk with reaper
                    style = style & ~(WS_SYSMENU);
                    style = style & ~(WS_BORDER);
                    style = style & ~(WS_HSCROLL);
                    style = style & ~(WS_VSCROLL);
                    style = style & ~(WS_SIZEBOX);
                    style = style & ~(WS_CAPTION);
                    SetWindowLong(pdGuiWindow,GWL_STYLE,style);
                    MoveWindow(pdGuiWindow, 0,0,((pdvst *)this->effect)->customGuiWidth,((pdvst *)this->effect)->customGuiHeight,TRUE);
                    systemWindowHidden=true;
                }
            }
        }
    AEffEditor::idle();
}
示例#29
0
static BOOL
AddAppMsgQueue(HTASK hTask,WORD loc,HWND hWnd,UINT wMsg,
				WPARAM wParam,LPARAM lParam)
{
	MSG	msg;

	/* can handle case of hWnd == 0 or hWnd == HWND_BROADCAST */
	/* hWnd == 0		my queue  	 */
	/* hWnd == HWND_BROADCAST	all top windows  */

	/* if driver is blocked (e.g., via select()) waiting for an event,
	 * then Post*Message() won't work, so tell driver to unblock first.
	 */
	DRVCALL_EVENTS(PEH_UNBLOCKSELECTWAIT, 0, 0, 0);

#ifdef	DEBUG
	memset((LPSTR)&msg,'\0',sizeof(MSG));
#endif

	msg.message = wMsg;
	msg.wParam  = wParam;
	msg.lParam  = lParam;

        if(hWnd == HWND_BROADCAST) {
		/*send to all top level windows */
		return EnumWindows((WNDENUMPROC)MultiPostMsg,
			(LONG)(LPMSG) &msg);
        }
	else {
	    	HWND32 hWnd32 = CHECKHWND32(hWnd);

		if (hWnd32 && (hWnd32->dwWinFlags & WFDEAD)) {
		        RELEASEWININFO(hWnd32);
		    	return 0;
		}
	}
	
	msg.hwnd = hWnd;

	RELEASEWININFO(hWnd32);

	return(QueueAddMsg(hTask,loc,&msg));
}
HWND CFifa2AutoLauncher::StartLauncherWindow()
{

	if(FALSE == StartLauncherProcess()) {
		return NULL;
	}

	m_hMainWindow = NULL;
	int iCount = 0;

	while (iCount < m_iTimeoutCount && UNKNOWN == m_state) {

		EnumWindows(CFifa2AutoLauncher::EnumWindowsProc, (LPARAM)this);
		::Sleep(m_iTimeoutSeconds);

	}

	return m_hMainWindow;
}