|
Hi all,
I'm using the GetWindowThreadProcessId function, but for some or other reason the function causes an exception. This is what I'm doing...
<br />
char* wndName = "WindowName";<br />
HWND hWnd = NULL;<br />
LPDWORD lpdwProcessId;<br />
int rc;<br />
<br />
hWnd = ::FindWindow(NULL,wndName);<br />
<br />
rc = GetWindowThreadProcessId(hWnd,lpdwProcessId);<br />
<br />
return rc;<br />
Anyone know what I'm doing wrong??
Thanx in advance
Regards
Programm3r
|
|
|
|
|
You're using an uninitialised pointer ("lpdwProcessId"). Try this instead:
const char *pWndName = "WindowName";
HWND hWnd = ::FindWindow(NULL, pWndName);
DWORD ProcessId;
DWORD ThreadId = GetWindowThreadProcessId(hWnd, &ProcessId);
return ProcessId;
Steve
|
|
|
|
|
Thanx Steve....
Regards
Programm3r
|
|
|
|
|
, Need to refresh page frequently.
|
|
|
|
|
Programm3r wrote: LPDWORD lpdwProcessId;
//return value
int rc;
//get a window handle
hWnd = ::FindWindow(NULL,wndName);
//get the pid of the process that created the window
rc = GetWindowThreadProcessId(hWnd,lpdwProcessId);
Again , here you are passing invalid memmory to function GetWindowThreadProcessId .
Use DWORD dwProcessId; instead and pass its address as parameter.
,Stephan has already answered this.
|
|
|
|
|
Prasad, thank you for the concern and help...
I got it working
Regards
Programm3r
|
|
|
|
|
What kind of problem u got
|
|
|
|
|
Problem solved ... thanx for the concern..
Regards
Programm3r
|
|
|
|
|
Hi guys,
I have added ToolBars and MenuBars from the Resource. I want to show more than 1 toolbars and menubars in my SDI Application. Can any one plz show how to display the menu bars and tool bars.
Thanks in Advance
Velayudhan
|
|
|
|
|
Did you search in codeproject?
|
|
|
|
|
Hi All,
Do any one know abt problems in DDX.
I can send data from Control to variable but when I tried to send data from variable to control my application get hangs.
I had created the dialog using CreateIndirect method.
|
|
|
|
|
|
I am not getting any error,
I craeted Tab control dialog then i called two other dialogs in tab control using Create Indirect Method.
I am able to enetered data in dialog boxe controls and I can send them in Database also, but when I try to send date to control from member variable application get hangs.
|
|
|
|
|
Now application got abort and it had breaked and in debugging it showed below code.
CStringData* GetData() const throw()<br />
{<br />
<big>---></big> return( reinterpret_cast< CStringData* >( m_pszData )-1 );<br />
}
Can you pls explain what is meant by this.
|
|
|
|
|
|
Means to find when some process is running example notepad.exe or word.exe is running in OS. How can I find if notepad.exe is running in OS.
|
|
|
|
|
<br />
HANDLE h_pro;<br />
HANDLE h_sna;<br />
PROCESSENTRY32 pe_sen = {0};<br />
<br />
int result;<br />
bool returnValue;<br />
bool counter = false;<br />
<br />
char* ProcessNames = appName;
<br />
h_sna = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br />
if (h_sna == INVALID_HANDLE_VALUE){<br />
returnValue = false;<br />
return (returnValue);<br />
}<br />
<br />
pe_sen.dwSize = sizeof(PROCESSENTRY32);<br />
<br />
try{<br />
if (Process32First(h_sna, &pe_sen))<br />
{<br />
do<br />
{<br />
h_pro = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pe_sen.th32ProcessID); <br />
CloseHandle (h_pro);<br />
<br />
if (pe_sen.th32ProcessID != 0)<br />
{<br />
result = strcmp (pe_sen.szExeFile,ProcessNames);<br />
<br />
if(result > 0){ <br />
returnValue = false;<br />
}<br />
else if (result < 0){ <br />
returnValue = false;<br />
}<br />
else<br />
{<br />
globalVariable = pe_sen.th32ProcessID;<br />
counter = true;<br />
}<br />
}<br />
} while (Process32Next(h_sna, &pe_sen));<br />
} <br />
}<br />
catch(...)<br />
{ <br />
returnValue = false;<br />
}<br />
<br />
if (counter)<br />
return counter;<br />
return returnValue;<br />
<br />
CloseHandle (h_sna);<br />
Regards
Programm3r
|
|
|
|
|
What more can you ask for....
Regards
Programm3r
|
|
|
|
|
Thanks for ur kind help
|
|
|
|
|
Did you come right????
Regards
Programm3r
|
|
|
|
|
|
Thank u I will try this one
|
|
|
|
|
Hi,
How can i declare a global variable which can be shared between different projects.
All these projects are under one workspace.
There is one main project which starts the application.
workspce trial.
proj1
proj2
proj3
proj4
proj5
proj3 is a dialog based main application and the other projects are Activex/Dialog based
I want to declare a variable in proj3 and access this variable from other projects.
Thanks,
kk_mfc
|
|
|
|
|
You would have to make use of header files and make sure the same header is included in all of the projects.
|
|
|
|
|
kk_mfc wrote: global variable which can be shared between different projects
You can save the value in the registry location and then you can use it from any of your project. Alternatively you can write the value into a file and then access it from different projects.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|