Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: looking for good information / tutorials on threading Pin
Sauce!4-Nov-09 0:29
Sauce!4-Nov-09 0:29 
GeneralRe: looking for good information / tutorials on threading Pin
Rajesh R Subramanian4-Nov-09 0:57
professionalRajesh R Subramanian4-Nov-09 0:57 
QuestionPrinting dash line Pin
Shivani .B3-Nov-09 20:20
Shivani .B3-Nov-09 20:20 
QuestionRe: Printing dash line Pin
CPallini3-Nov-09 21:57
mveCPallini3-Nov-09 21:57 
AnswerRe: Printing dash line Pin
Shivani .B3-Nov-09 22:01
Shivani .B3-Nov-09 22:01 
GeneralRe: Printing dash line Pin
CPallini3-Nov-09 22:40
mveCPallini3-Nov-09 22:40 
AnswerRe: Printing dash line Pin
Shivani .B3-Nov-09 23:01
Shivani .B3-Nov-09 23:01 
QuestionProblem in Getting Window handler Pin
NarVish3-Nov-09 19:31
NarVish3-Nov-09 19:31 
Hi,
From all the system processes, I'm trying to get window handler for the excel processes.
At line,
HRESULT hr = AccessibleObjectFromWindow(hwnd, OBJID_NATIVEOM, __uuidof(Excel::Window), (void**)&pWindow);
I'm getting "FAILED" message. Complete code is given below. Please guide me to get value in pWindow. Thanks in advance.

#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <tchar.h>
#include <psapi.h>
#include<oleacc.h>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
#import "libid:00020813-0000-0000-C000-000000000046" auto_search no_dual_interfaces \
	rename("DialogBox", "excelDialogBox") \
	rename("RGB", "excelRGB") \
	rename("DocumentProperties", "excelDocumentProperties") \
	rename("SearchPath", "excelSearchPath") \
	rename("CopyFile", "excelCopyFile") \
	rename("ReplaceText", "excelReplaceText")
 
int _tmain(int argc, _TCHAR* argv[])
{
 // Get the list of process identifiers.
    DWORD aProcesses[1024], cbNeeded, cProcesses;
    unsigned int i;

    if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
        return 1;

    // Calculate how many process identifiers were returned.
    cProcesses = cbNeeded / sizeof(DWORD);
	  
    // Print the name and process identifier for each process.
    for ( i = 0; i < cProcesses; i++ )
	{
        if( aProcesses[i] != 0 )
		{
			TCHAR szProcessName[MAX_PATH] = _T("<unknown>");
			HWND hwnd;
			// Get a handle to the process.
			HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i] );

			// Get the process name.
			if (NULL != hProcess )
			{
				HMODULE hMod;
				DWORD cbNeeded;
	        
				if ( EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded) )
				{
					GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
  
					if(_wcsicmp(szProcessName,L"EXCEL.EXE") == 0)		 
					{
						std::cout<< szProcessName << "--" << aProcesses[i] <<endl;
						Excel::Window* pWindow = NULL;
                                                //getting failed in the below line.
						HRESULT hr = AccessibleObjectFromWindow(hwnd, OBJID_NATIVEOM, __uuidof(Excel::Window), (void**)&pWindow);

						if (hr == S_OK)
						{
						}
						else
						{
							std::cout<<"Failed";
						}  
					}
				}
			}

			// Print the process name and identifier.
			_tprintf( TEXT("%s  (PID: %u)\n"), szProcessName, aProcesses[i] ); 
			CloseHandle( hProcess );
		}
	} 
	return 0;
}

AnswerRe: Problem in Getting Window handler Pin
Richard MacCutchan3-Nov-09 22:59
mveRichard MacCutchan3-Nov-09 22:59 
AnswerRe: Problem in Getting Window handler Pin
David Crow4-Nov-09 3:15
David Crow4-Nov-09 3:15 
Questionhow to disable alert script in webbrower ? Pin
Member 37001883-Nov-09 19:14
Member 37001883-Nov-09 19:14 
AnswerRe: how to disable alert script in webbrower ? Pin
enhzflep3-Nov-09 20:49
enhzflep3-Nov-09 20:49 
QuestionDetecting when a user copy a file in windows explorer Pin
emmmatty13-Nov-09 19:00
emmmatty13-Nov-09 19:00 
QuestionRe: Detecting when a user copy a file in windows explorer Pin
David Crow4-Nov-09 3:17
David Crow4-Nov-09 3:17 
AnswerRe: Detecting when a user copy a file in windows explorer Pin
emmmatty14-Nov-09 3:42
emmmatty14-Nov-09 3:42 
QuestionMemory leak: Tracking line numbers in VS2005 Pin
PaulowniaK3-Nov-09 17:58
PaulowniaK3-Nov-09 17:58 
AnswerRe: Memory leak: Tracking line numbers in VS2005 Pin
Saurabh.Garg4-Nov-09 1:10
Saurabh.Garg4-Nov-09 1:10 
GeneralRe: Memory leak: Tracking line numbers in VS2005 Pin
PaulowniaK4-Nov-09 13:59
PaulowniaK4-Nov-09 13:59 
GeneralRe: Memory leak: Tracking line numbers in VS2005 Pin
Saurabh.Garg4-Nov-09 15:52
Saurabh.Garg4-Nov-09 15:52 
QuestionCmake cannot find my header file. Pin
meiskru3-Nov-09 17:30
meiskru3-Nov-09 17:30 
QuestionRe: Cmake cannot find my header file. Pin
CPallini3-Nov-09 20:50
mveCPallini3-Nov-09 20:50 
Questionwhat are the different manners to run a file auto in WindowsXP Pin
WindowsVsLinux3-Nov-09 16:16
WindowsVsLinux3-Nov-09 16:16 
AnswerRe: what are the different manners to run a file auto in WindowsXP Pin
Rajesh R Subramanian3-Nov-09 19:16
professionalRajesh R Subramanian3-Nov-09 19:16 
QuestionSplitting window at runtime Pin
Anu_Bala3-Nov-09 16:15
Anu_Bala3-Nov-09 16:15 
AnswerRe: Splitting window at runtime Pin
«_Superman_»3-Nov-09 16:22
professional«_Superman_»3-Nov-09 16:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.