|
GDay everyone,
Is there any way to terminate the child process from the parent process in C programming?
Please give me an advice.
Thanks
eric
|
|
|
|
|
eric_tran wrote: terminate the child process from the parent process
TerminateProcess().
Also from MSDN:
If you need to have one process terminate another process, the following steps provide a better solution:
Have both processes call the RegisterWindowMessage function to create a private message.
One process can terminate the other process by broadcasting the private message using the BroadcastSystemMessage function as follows:
BroadcastSystemMessage(
BSF_IGNORECURRENTTASK, // do not send message to this process
BSM_APPLICATIONS, // broadcast only to applications
private message, // message registered in previous step
wParam, // message-specific value
lParam ); // message-specific value
The process receiving the private message calls ExitProcess to terminate its execution.
See if either helps you...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
if u create a process using the CreateProcess API, u will get the handle of that process. So when u want to kill that process u call TerminateProcess() with that handle.
nave
|
|
|
|
|
How to create this process?
|
|
|
|
|
How can i detect which drive is alloted to USB drive and how can i know USB drive is inserted or not?
|
|
|
|
|
Hello. Here is the code I use for finding the number of drives that are removeable, RAM-drives or drives connected via USB.
The source code isn't UNICODE aware, it doesn't use STL/ATL, it's mainly pure C-code.
Fill in the blanks when it comes to code shortcomings...
However, it does work...
<br />
long GetRemoveableDriveCount()<br />
{<br />
<br />
int i;<br />
char sDrivePath[3];<br />
UINT uDriveType;<br />
DWORD dwDrives;<br />
fRemovableDrives = 0;<br />
int noOfDrives = 0;<br />
<br />
dwDrives = GetLogicalDrives();<br />
<br />
strcpy(sDrivePath+1, ":\\");<br />
<br />
for(i = 0; i < 32; i++) {<br />
if(dwDrives & (1 << i)) {<br />
sDrivePath[0] = (char) ('A' + i);<br />
uDriveType = GetDriveType(sDrivePath);<br />
<br />
if((uDriveType == DRIVE_REMOVABLE || uDriveType== DRIVE_RAMDISK)) {<br />
fRemovableDrives |= (1 << i);<br />
noOfDrives++;<br />
}<br />
else {<br />
if(uDriveType == DRIVE_FIXED) {<br />
char szBuf[10];<br />
HANDLE hDevice;<br />
PSTORAGE_DEVICE_DESCRIPTOR pDevDesc;<br />
<br />
sprintf(szBuf, "\\\\?\\%c:", sDrivePath[0]);<br />
hDevice = CreateFile(szBuf, 0,<br />
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);<br />
<br />
if (hDevice != INVALID_HANDLE_VALUE)<br />
{<br />
pDevDesc = (PSTORAGE_DEVICE_DESCRIPTOR)new BYTE[sizeof(STORAGE_DEVICE_DESCRIPTOR) + 512 - 1];<br />
<br />
pDevDesc->Size = sizeof(STORAGE_DEVICE_DESCRIPTOR) + 512 - 1;<br />
<br />
if(GetDisksProperty(hDevice, pDevDesc))<br />
{<br />
if(pDevDesc->BusType == BusTypeUsb)<br />
{<br />
<br />
fRemovableDrives |= (1 << i);<br />
noOfDrives++;<br />
}<br />
}<br />
<br />
delete pDevDesc;<br />
CloseHandle(hDevice);<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
return noOfDrives;<br />
}<br />
<br />
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
-- modified at 4:47 Monday 25th September, 2006
|
|
|
|
|
|
Can some please tell me where i can
get some information regrading whitebox testing tools in vc++
or some information regrading it / URL ..
Thanks in Advance
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
Hi All,
I am getting this error " Can not Open precompiled header file " .
Why is this coming ?
What is this ?
|
|
|
|
|
He he.. Build your program.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
include "StdAfx.h"
in the first line of ur source code
cheers
|
|
|
|
|
A precompiled header is the stdafx.h file in your project. If you're using precompiled headers, the first include in all of your .cpp files needs to be this file. Any files included before it will be ignored. People often get errors with this, if they find a cpp file on the web and put it into their project, but it doesn't include the file.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If they are new to VC6.0 IDE and they are compiling their first program, they'll certainly find it saying "Cannot Open precompiled header file : TheirProgram.pch". I thought that could be the case
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
i downloaded a program from the Internet. It reference s a header file file called sockets.h. When i try to run my program, i get a compile error saying that sockets.h wasn't found. Quite a few other header files are missing too. How can i resolve this?
|
|
|
|
|
Did you see that site for sockets.h
|
|
|
|
|
I'm sorry, i couldn't understand what you meant.
|
|
|
|
|
mostly this would be the problem with the #include<> and #include" ".. or you sure you used #include "sockets.h" I mean if you have the file. If you dont have it, search for it. No other way.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
i used #include<>. I guess i'll have to find the file on Google.
|
|
|
|
|
if the header file is stored locally, I mean where the .cpp files are stored, you should use #include "myheader.h"
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
You download a program of internet what files is in this program
|
|
|
|
|
I don't see, if sockets.h is a platform/SDK header. Try commenting that header, whether error you would get for functions; are application specific or somethig else.
|
|
|
|
|
i tried to find the file using Windows Search but i coudn't find it. It there another library i could use for socket programming.
|
|
|
|
|
so is this what you've beeing trying to do? You have lovely API for thatWinSock Search CP for "Winsock". You'll need to scroll for pages.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
As I said, it could be other applicatin specific header. Try commenting it out.
Mridang Agarwal wrote: It there another library i could use for socket programming.
If you are using MFC , you can go with Socket classes.
Otherwise use winsock[^].
|
|
|
|