|
Is there any way to get Grand Child of a process
|
|
|
|
|
On Win9X and 2000 (not NT4) you can use TOOLHELP api. You call CreateToolhelp32Snapshot, then iterate over the snapshot using Process32First/Process32Next. Process32xxx functions fill PROCESSENTRY32 structure, and one of the members is th32ParentProcessID - check it to determine the parent-child relationships.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I need to test a program that sends and receives data over a serial port. It will eventually connect to some specific hardware, but for the moment I need a program that will emulate the responses the hardware would give. So here's my problem. . .
Program 1 will send and get data on the serial port.
Program 2 will respond over the serial port to Program 1.
Program Proxy will redirect the communication from the actual serial port to the programs (ie Program 1 sends data, the proxy redirects it from the serial port to Program 2).
Program 1 and 2 are easy (they will just use standard Serial communication protocol). However, the Proxy is where I am getting caught. Does anyone know how I can get information being written to the serial port and redirect it to another program on the same machine?
Thanks
Zac
|
|
|
|
|
I think you could either:
1) Get another serial port and wire it up to your existing one in a loopback.
2) Use named pipes for the comms while you are testing instead of serial port.
Either way there is no need for the proxy program.
|
|
|
|
|
I use spawncl(...) to run other applications.
I then get the hWnd of the new application.
(i use a hook to see when a wnd is created/activated/destroyed)
The fuction ::GetWindowText(...) works fine and i get the windows title.
But when i call ::GetWindowModuleFilename(...) i get the filename of
my application, not the new one.
If i run Task manager, i can see the filename of the new application!
What can i do? Is there another way to get the filename instead
of ::GetWindowModuleFilename(...) , or i souldn't use spawn(...)
and use CreateProcess(...) or RunWin(...) ?
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
What exactly is the problem? You are passing the executable filename to the spawn/CreateProcess/WinExec. Why do you want to retrieve it using hwnd? Do you think Windows is replacing your exe with something else?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
How can i disagree.
You are right!
I didn't describe it correctly.
My application sets a system hook to
get notified for all created windows.
That's why i want to get the filename
from the hWnd. It's not limited to the
programs that i run with spawn*(...).
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
How can i disagree.
You are right!
I didn't describe it correctly.
My application sets a system hook to
get notified for all created windows.
That's why i want to get the filename
from the hWnd. It's not limited to the
programs that i run with spawn*(...).
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
This doesn't work on NT or Win2K!
See http://msdn.microsoft.com/library/psdk/winbase/psapi_9cc3.htm
Mh2x
|
|
|
|
|
I quess i have to do the following:
DWORD ProcessID;
GetWindowThreadProcessId(hWnd,&dwProcessID);
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION| PROCESS_VM_READ,FALSE, processID );
HMODULE hMod;
DWORD cbNeeded;
EnumProcessModules( hProcess, &hMod, sizeof(hMod),&cbNeeded);
GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName) );
CloseHandle( hProcess );
i will try it tonight.
Thanks.
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
Is there an easy way to create a dialog app that when executed doesn't appear but is still running in the background?
Thanks in advance!!
Rob Jones
|
|
|
|
|
Do you expect your dialog to be always invisible? Or only until some event occurs?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
|
If your app targets NT/W2K only, you can consider creating a service. If you need to run on Win9x, hiding main window should work.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I Use ShowWindow(SW_HIDE)
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
I *finally* figured out how to use the CTime class successfully...
CTime CurrentTime = CTime::GetCurrentTime();
or
CTime CurrentTime;
//blah blah
CurrentTime = CTime::GetCurrentTime();
I don't get it. Why do you have to do it that way, and why doesn't the following work...
CTime CurrentTime;
CurrentTime.GetCurrentTime();
- John
------------------------------------------------
Before you critisize a man, walk a mile in his shoes. Then when you critisize him, you are a mile away and have his shoes.
|
|
|
|
|
CTime tm = CTime::GetCurrentTime();
If you want to Know the Hour or the minutes, you can do:
CTime tm = CTime::GetCurrentTime();
int nHour = tm.GetHour();
int nMin = tm.GetMinute();
etc.
Regards...
Carlos Antollini.
|
|
|
|
|
I think my question was unclear. I don't understand why the CTime object has to be initialized that way. Why can't it be initialized like this:
CTime tm;
tm.GetCurrentTime();
- John
|
|
|
|
|
Because the definition of GetCurrentTime is
CTime GetCurrentTime(); And not void CTime::GetCurrentTime();
I think that this is a cuestion for the Microsoft Developers.....
Is True, Is more is more intuitive of the other form, but they developed it of that
way.
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
I'm not sure of the exact implementation details, but did you notice that the GetCurrentTime method of the CTime class is a 'static' method? That is the reason for how it is used. Why it's declaration is such, I don't know. That relates to how the developers decided to do things.
Chris
|
|
|
|
|
Yeah GetCurrentTime is a static method that is why you call it using that syntax. The method create a CTime object in this way CTime(::time(NULL)). The GetCurrentTime is creating a new CTime Object of which the member m_time contains the latest time.The assignment operator copies this value
CTime tm;
tm=CTime::GetCurrentTime();// operator=(const CTime& timeSrc) comes into action
Mail back if you have more info
|
|
|
|
|
Yeah GetCurrentTime is a static method that is why you call it using that syntax. The method create a CTime object in this way CTime(::time(NULL)). The GetCurrentTime is creating a new CTime Object of which the member m_time contains the latest time.The assignment operator copies this value
CTime tm;
tm=CTime::GetCurrentTime();// operator=(const CTime& timeSrc) comes into action
Mail back if you have more info
|
|
|
|
|
Hello all,
I want to include an excel-type chart in my app. How can I add controls like the data grid and chart control in vc++ its easy in visual basic. Can I do similar things in VC++ 6?
Thankyou
|
|
|
|
|
Its easy to do... For example if you have just created a dialog type application you can right click on the dialog and pick Insert ActiveX Control, from here you can pick your ActiveX grid or excel controls.. or from the the menu bar in Visual C++ pick "Project" then "Add to Project" next chose components and controls.. then go to Registered ActiveX Controls folder.
Have Fun!
Rob Jones
|
|
|
|
|
Hi:
I´ve define a dual interface with connection points in VC++, and I want to send data to VB, but I don´t know what have to put in VB to finish the connection. Cuold someone help me? I would grateful if you would send me an example code. Thanks.
![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|