Click here to Skip to main content
15,902,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm running this code I got of the Microsoft site. however;I not getting any return to the console screen even though I have several instances of notepad running. Any help is appreciated. Thanks.

C++
public:
static array<process^>^ GetProcesses(
	String^ machineName
)
#include "stdafx.h"
#include <iostream>

#using <system.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
int main()
{
   Process^ currentProcess = Process::GetCurrentProcess();
   array<process^>^localByName = Process::GetProcessesByName( "notepad" );
}
Posted
Updated 11-Sep-11 20:37pm
v3

1 solution

Ok from what I can understand; You expect the posted code to write something to the console.
It does not and that is to be expected as you're not writing anything. If you want to write something to the console then you should use the Console class[^] e.g. Console.WriteLine("Writing to console");
 
Share this answer
 
Comments
Member 7766180 10-Sep-11 14:32pm    
Thank you Simon. Next question, I was expecting it to print out how many instances of notepad are runnibg, What do I need to do? Thanks.
Simon Bang Terkildsen 10-Sep-11 14:54pm    
Console::WriteLine(localByName.Length); will write the size of the array to the console, so the number of the processes will be writen to the console.
Member 7766180 10-Sep-11 15:04pm    
Thank you, Simon. I'm getting this message now.
warning C4817: 'System::Array::Length' : illegal use of '.' to access this member; compiler replaced with '->'
Simon Bang Terkildsen 10-Sep-11 15:08pm    
Damn, my lack of familiarity with C++/CLI is exposed :P
Replace the . with -> and the warning will disappear
Member 7766180 10-Sep-11 15:09pm    
Thank you. Did that no more errors! But no return of data either, even though I have two instances of notepad running. Flashes closed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900