IGuestProcess

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
hilly
Posts: 8
Joined: 20. Aug 2013, 07:49

IGuestProcess

Post by hilly »

hi all,

readonly attribute IGuestProcess [] IGuestSession::processes
Returns all current guest processes.
I am using guestsession->get_processes
but it always returns 0.
I understood it as it will return me list of processes running inside guest.
is it correct? then why it should return 0 processes.
please help.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: IGuestProcess

Post by noteirak »

Could you give a sample code to reproduce this, as well as the virtualbox version and the language you are using.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
hilly
Posts: 8
Joined: 20. Aug 2013, 07:49

Re: IGuestProcess

Post by hilly »

i am using c++ api given by virtualbox

guest session is created using createsession..
and then following is the code.

Code: Select all

				SAFEARRAY *aProcesses = NULL;
				HRESULT rcp;
				rcp = gSession->get_Processes(&aProcesses);
				if(SUCCEEDED(rcp))
				{
					IGuestProcess **iProcesses;
					hr_de = SafeArrayAccessData(aProcesses, (void **)&iProcesses);
					if(SUCCEEDED(hr_de))
					{
							ULONG cnt_elements = aProcesses->rgsabound[0].cElements; 

 						printf("number of proces %d. \n", cnt_elements); // [b]this is always coming to 0[/b].
						for(ULONG i=0; i<cnt_elements; i++)
						{	
							BSTR aName;
							ULONG aPid;
							iProcesses[i]->get_Name(&aName);	
							iProcesses[i]->get_PID(&aPid);
							printf("%d::", i);
							printf("%d. %S \n", aPid, aName);
							SysFreeString(aName);
						}
						SafeArrayUnaccessData(aProcesses);
					}
					else
					{					
						IErrorInfo *errorInfo;
						rc = GetErrorInfo(0, &errorInfo);
						BSTR errorDescription = NULL;
						rc = errorInfo->GetDescription(&errorDescription);
						printf("getiing process data: %S\n", errorDescription);
						SysFreeString(errorDescription);
					}
					SafeArrayDestroy(aProcesses);
				}
				else
				{
					IErrorInfo *errorInfo;
					rc = GetErrorInfo(0, &errorInfo);
					BSTR errorDescription = NULL;
					rc = errorInfo->GetDescription(&errorDescription);
					printf("getiing process list: %S\n", errorDescription);
					SysFreeString(errorDescription);
				}
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: IGuestProcess

Post by noteirak »

Could you validate that :
- The machine is running
- The guest additions are installed and running on the machine
- The guest additions are the same version as Virtualbox on the host

If yes to all of the above, please post a self-sufficient code, as described in the Posting Guidelines of this section. I do not see how you get your guest session so I cannot really help you further until then.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
bonibom
Posts: 7
Joined: 2. Jun 2014, 21:00

Re: IGuestProcess

Post by bonibom »

attribute IGuestProcess [] IGuestSession::processes returns list of processes
that are started in a guest session that you create rather then list of all processes running on a guest.
And one more thing: if you create an instance of IGuestSession and start a process(es) in a guest
and then perform guest_session_instance.Close(), the process(es) will be terminated
Post Reply