Display all processes in a ComboBox when it's clicked

This is what I've done so far...
What's wrong with it?
1
2
3
4
5
6
7
8
9
10
11
12
13
private: System::Void comboBox2_Click(System::Object^  sender, System::EventArgs^  e) {
			 DWORD aProcesses[1024], cbNeeded, cProcesses;
			 std::string sProcessName = "";
			 int i;
			 EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded );
			 cProcesses = cbNeeded / sizeof(DWORD);
			 for (i = 0; i < cProcesses; i++)
			 {
				 HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i]);
				 GetModuleBaseName(hProcess,NULL, sProcessName, 100);
				 this->comboBox2->Items->Add(sProcessName);
			 }
		 }

I get this when I debug it:
1
2
3
4
5
6
warning C4018: '<' : signed/unsigned mismatch
error C2664: 'GetModuleBaseNameW' : cannot convert parameter 3 from 'std::string' to 'LPWSTR'
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
error C2664: 'System::Windows::Forms::ComboBox::ObjectCollection::Add' : cannot convert parameter 1 from 'std::string' to 'System::Object ^'
1>        No user-defined-conversion operator available, or
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called


What am I doing wrong?
Last edited on
win32 code is 'C' code, you cannot use c++ in that.
instead of passing std::string, pass a char*. this is what it is saying.
error C2664: 'GetModuleBaseNameW' : cannot convert parameter 3 from 'char *' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: 'System::Windows::Forms::ComboBox::ObjectCollection::Add' : cannot convert parameter 1 from 'char *' to 'System::Object ^'
1> No user-defined-conversion operator available, or
1> Cannot convert an unmanaged type to a managed type
Last edited on
Topic archived. No new replies allowed.