|
How can i obtain the process handle of any process under execution ??? Actually, i am writing an application that can terminate any process. For this purpose i am using API TerminateProcess():
BOOL TerminateProcess(<br />
HANDLE hProcess,<br />
UINT uExitCode<br />
)
As can be seen from the syntax, the first argument is the process handle. How can i obtain this handle when i only know is the process name ???? Is there any other alternative you suggest me instead of TerminateProcess() ???
|
|
|
|
|
For this you need to look on the following API's
CreateToolhelp32Snapshot for a snapshot of running process on your machine and on successful exec. of this function you need to iterate the processes using Process32First followed by Process32Next.
Also look at the following API's in MSDN
GetProcessModule
OpenProcess
HTH
Cheers
Kannan
|
|
|
|
|
Is it possible to have an MFC document template be able to open multiple file types?
(whatever.bla and whatever.beh for example)
|
|
|
|
|
You have to manually edit the IDR_XXXXTYPE string in the resource file to add your file types to the
File Open box.
If you search MFC for a function called
CDocTemplate::Confidence CDocTemplate::MatchDocType(LPCTSTR lpszPathName, CDocument*& rpDocMatch)
{
}
It will show how MFC chooses which template to use for any given file type. You can inherit from
C(Multi/Single)DocTemplate, and override this function to do clever "type choosing things".
You'll have to remember to trivially override the construction member as well...
As before, I hope this gives you pointers...
Iain.
|
|
|
|
|
Thanks, but what do I put in the string? I tried doing it like normal open file dialogs, but |s didn't work and I don't know what else to try...
|
|
|
|
|
What string? You mean the lpszPathName or what?
|
|
|
|
|
I may have been misleading you... I misremembered how I did the project I thought I had this
feature in. The string I meant was as follows:
// Normal
JigSaw\n\nJigSaw\nJigsaw Image (*.jig)\n.jig\nJigSaw.Document\nJigSaw Document
// Edited...
JigSaw\n\nJigSaw\nJigsaw Image (*.jig;*.jpg)\n.jig;.jpg\nJigSaw.Document\nJigSaw Document
OR
JigSaw\n\nJigSaw\nJigsaw Image (*.jig;*.jpg)\n.jig;*.jpg\nJigSaw.Document\nJigSaw Document
If those two possibilities don't work, then you'll have to use the OpenFileName function
yourself by over-riding the CWinApp::OnFileOpen () function.
Loosely, and with a lot or error correction cut out:
void CZeusApp::OnFileOpen()
{
CFileDialog fDlg (TRUE, "JIG", NULL, 0, "Jigsaw Image (*.jig;*.jpg)|mdf;*.dat|All files|*.*||", AfxGetMainWnd ())
if (fDlg.DoModal () != IDOK)
return;
OpenDocumentFile (fDlg.GetPathName ());
}
This wouldn't handle multiple files etc, but it will give you a start.
Iain.
|
|
|
|
|
Respected sir/madam
my problem is how to call the api's viz
GetTcpTable & SetTcpEntry???
These are available in the dll file "iphlpapi.dll" but when i include the header file iphlpapi.h it is showing two errors as follows
1) unknown pragma #pragma option
2) cannot include header file iptypes.h
i also tried loading the dll using LoadLibrary & invoke the above told functions using the GetProocAddres function.
But this shows assertion failure....
so kindly do tell me how to invoke those functions...
prince
|
|
|
|
|
I don't know what's wrong with header file.
About DLL:
Make sore that function poiters are CALLBACK as:
typedef void (CALLBACK* SomeName)(BOOL, and so on..)
viliam
|
|
|
|
|
How can I use a custom resource in the program?
I added a resource that I need to use as plain binary data, but can't seem to find a function to do it.
|
|
|
|
|
My server application may freeze and stops responding. So a second application continuously monitors it after every few minutes. If second application is unable to get a response from the server application, it assumes that the server is dead and then need to take control of the port and itself start listening for a temporary period.
Is it possible that the second app start listening on a port already bind to the previous app ??? If yes, then how ??
|
|
|
|
|
Nope.
A port has to be released before you can bind to it again.
If you manage to kill the other process and then wait for the
"port shutdown timeout" (forgot what's actually called) then you
can reuse the port.
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
Hi All,
I need to know a way to programmatically know how we can determine the file system on the system disk. Is there any API available which can be used to determine the file system.
Thanks and regards,
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Call GetVolumeInformation() - one of the things it returns is the name of the file system.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Is there a better way to updating the first pane in a MFC statusbar than just calling it's SetPaneText function when you want it changed? An UI update handler somehow?
And when exactly does MFC change it to "For help, press F1" and is it possible to change that?
|
|
|
|
|
If you look in tech note 27 in the Visual C++ 6 docs, it talks about WM_SETMESSAGESTRING, which is a
MFC defined message sent to the CFrameWnd. In 99% of cases, this will be CMainFrame. The handle for
this message then tells the status bar what to display. You could simply send this message yourself.
As for your second question, CFrameWnd has a handler for the WM_MENUSELECT to get the current menu
item, and extract the text from the string table.
I hope that gave you some pointers,
Iain.
|
|
|
|
|
Hi,
When a Win2K or XP computer waits for you to press Ctrl+Alt+Del to log on, Windows displays a virtual keyboard if you press another button.
Is it possible to display this keyboard in my own app?
Best regards
/Nyrup
|
|
|
|
|
It's an "AVI" resource in msgina.dll
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi,
Thanx for your fast answer!
An AVI..... sad... I had hoped for an interface, so I could point on other keys. I guess I don't get this feature without some effort
Thanks again
/Nyrup
|
|
|
|
|
Hi all. I really need some help.
My problem is with inheritance. I have a class type that I want to use several times over for a few VERY similar structures (only 1 variable different). The class mainly contains a linked list, however I don't want to re-write many of the functions just to support the ONE different data type. I have tried doing it this way without success:
<br />
class cGeneric<br />
{<br />
public:<br />
typedef char* DataType;<br />
<br />
struct Node<br />
{<br />
DataType Id;<br />
char *pData;<br />
Node *pNext;<br />
};<br />
<br />
Node *First;<br />
public:<br />
<br />
bool AddItem(DataType Id, char *pData);<br />
<br />
...<br />
<br />
class cExtention : public cGeneric<br />
{<br />
public:<br />
typedef int DataType;<br />
<br />
struct Node<br />
{<br />
DataType Id;<br />
char *pData;<br />
Node *pNext;<br />
};<br />
<br />
Node *First;<br />
In the AddItem function, it just passes the Id (either char* or int) to another function. I know this doesn't work (it reads the information for AddItem from cGeneric since it isn't redefined in cExtention, and so therefore expects a char*) however I would like to know if there is another way to do this.
I haven't done much OOP and I find it a little difficult to swallow at times.
If anyone has ideas of how I could do this, I would greatly appreciate your feedback.
Lord Morlock
~o~
|
|
|
|
|
This is what templates were designed for.
template <typename DataType> class CGeneric
{
};
typedef CGeneric<int> CExtension; As long as AddItem() can deal with an arbitrary type, you're set.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks heaps! I knew there'd be a way... I just don't have any class oriented books for C++ atm .
One more question, I assume templates are C++, not just MS?
Thanks again.
Lord Morlock
~o~
|
|
|
|
|
Lord Morlock wrote:
One more question, I assume templates are C++, not just MS?
That's correct.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Please help me with this situation that I have. How can I detect which version of Windows is running, that is , is Windows 95, 98 ,2000, ME, XP or NT is running?
Regards
Nashdaq
|
|
|
|
|
Call GetVersionEx() , which fills in a struct with the version numbers and 9x/NT flag. MSDN has a table showing which version corresponds to 95, 98, etc.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|