[Forms] Parameter conversion issue (from wchar to System::String ^)

Hey there,

I'd like to create a list, of the running processes, using comboBox control to store the process names in. Unfortunately though, I've bumped into an error I can't seem to be able to fix by myself.

The idea is to add items to the comboBox (real time) while looping through the running processes.

---

An analog for the ease of understanding:

while(Process32Next(...))
{
comboBox1->Items->Add("NAME OF PROCESS IS SUPPOSED TO COME HERE");
}

However:

PROCESSENTRY32 proc;
...
proc.szExeFile // is of type 'wchar', while the Add function accepts 'System::String ^'. Obviously type-casting won't help, it involves something more advanced I don't know of.

Please note, I lack of C++ experience (and mainly OOP, which I am trying to get the hang of), so I am kind of clueless at this point.

Of course I had searched before opening the topic and found out about a function that does exactly the opposite thing: http://pastebin.com/f5d6256ee

Thank's in advance!



Last edited on
closed account (z05DSL3A)
1
2
3
4
5
6
7
8
9

    //using namespace System::Diagnostics;

    array<Process^>^localAll = Process::GetProcesses();

    for each(Process^ proc in localAll)
    {
        this->comboBox1->Items->Add(proc->ProcessName);
    }
Wow, thanks a bunch, compiles and works perfectly fine now! (Y)
Wouldn't have worked it out myself, now time to read about the way you used to approach the task. It's somewhat different than I thought.
Last edited on
Topic archived. No new replies allowed.