eCharcha.Com   Support eCharcha.Com. Click on sponsor ad to shop online!

Advertise Here

Go Back   eCharcha.Com > eCharcha Lounge > SoapBox


SoapBox Speak up, speak on, speak your heart out!

Thread Tools Display Modes
Old December 2nd, 2002, 10:17 AM
Posts: n/a
Question OS2 - Windows porting

Can anybody tell me how to get the list of all the processes in memory in windows ? I have this fukkin OS2 code that makes this call 'winQuerySwitchList' that returns somethin similar . Now I have to find the windows equivalent of this call.

Moreover, the code is written in Smalltalk . If someone can tell me the Win32 call, I will try and manage the Smalltalk part.

Reply With Quote
Old December 2nd, 2002, 11:15 AM
GunsNRoses's Avatar
GunsNRoses GunsNRoses is offline
Spear Barbarian
Join Date: Jun 2001
Posts: 1,263
GunsNRoses has much to be proud ofGunsNRoses has much to be proud ofGunsNRoses has much to be proud ofGunsNRoses has much to be proud ofGunsNRoses has much to be proud ofGunsNRoses has much to be proud ofGunsNRoses has much to be proud ofGunsNRoses has much to be proud ofGunsNRoses has much to be proud of
Here's a code snippet that I wrote a while back, that goes through the process list and kills processes of a specified name. I haven't bothered removing the code that kills the processes, but you should have no trouble finding and removing it. I haven't bothered to remove the slightly eccentric comments either, so I hope that you find it somewhat easy to understand. Enjoy! Hope this helps

void CTestDlg::SuperKill(CString sFileName)
	// Enumerate and terminate all processes named sFileName.
	// This is tough, but the forced logoff is tough, and the Explorer
	// shell will cause problems. So we use the super nuke option!

	HINSTANCE      hInstLib;
	HANDLE         hSnapShot;
	PROCESSENTRY32 procentry;
	BOOL           bFlag;

	// Declare our function pointers.
	HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD);

	hInstLib = LoadLibraryA( "Kernel32.DLL" );
	if( hInstLib == NULL ) {
		LogErrorState("SuperKill(): Could not load Kernel32.DLL");
		return; // This "Cannot Happen"

	// Get procedure addresses. We are linking to these functions of Kernel32
	// explicitly, because otherwise a module using this code would fail to load 
	// under Windows NT, which does not have the Toolhelp32 functions in the Kernel 32.
				 GetProcAddress( hInstLib,
				 "CreateToolhelp32Snapshot" );
				 GetProcAddress( hInstLib, "Process32First" );
				 GetProcAddress( hInstLib, "Process32Next" );

	if( lpfProcess32Next == NULL || lpfProcess32First == NULL ||
		lpfCreateToolhelp32Snapshot == NULL ) {
		// Cannot happen condition! 
		LogErrorState("SuperKill(): Could not load fn pointers in Kernel32.DLL"); 
		// Clean up before quitting
		FreeLibrary( hInstLib );

	// Get a handle to a ToolHelp snapshot of the systems processes.
	hSnapShot = lpfCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0 );
	if( hSnapShot == INVALID_HANDLE_VALUE ) {
		// Cannot happen condition! 
		LogErrorState("SuperKill(): Could not get snapshot of running processes!"); 
		FreeLibrary( hInstLib );

	// Get the first process's information.
	procentry.dwSize = sizeof(PROCESSENTRY32);
	bFlag = lpfProcess32First( hSnapShot, &procentry );

	// While there are processes, keep looping.
	while( bFlag )
	 {  // We need to see if the app is named sFileName.
		HANDLE hProcess;
		INT nPos;

		nPos = lstrlen(procentry.szExeFile);

		if (nPos)
		   while (procentry.szExeFile[--nPos] != '\\' );
			  // Terminate the process.
			  hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE, procentry.th32ProcessID);
			  TerminateProcess(hProcess, 1);


	 procentry.dwSize = sizeof(PROCESSENTRY32) ;
	 bFlag = lpfProcess32Next( hSnapShot, &procentry );


	// Free the library. We're outta here
	FreeLibrary( hInstLib ) ;
"Pick up your balls and load up your cannon
For a twenty-one gun salute."
-- For Those About To Rock (We Salute You)

Proud LLKC member since May 2002.
"We've been looking for the enemy for some time now. We've finally found him. We're surrounded. That simplifies things." Lt. Gen. Lewis "Chesty" Puller, USMC, Chosin Reservoir 1950

Reply With Quote
Old December 3rd, 2002, 05:34 AM
Posts: n/a
Havent tried the code yet. But still thanks for replying GnR.
Reply With Quote


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
You just cannot con Windows echarcha Computing 3 October 10th, 2005 09:58 AM
Windows XP x64 padhu Computing 3 August 9th, 2005 02:56 PM
How Many Windows? Diplomat Computing 20 June 8th, 2003 10:01 PM
in windows xp! loverboy260 SoapBox 22 July 15th, 2002 04:43 PM
has anyone got windows xp? loverboy260 SoapBox 12 May 29th, 2002 02:39 AM

All times are GMT -7. The time now is 06:11 AM.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Site Copyright © eCharcha.Com 2000-2012.