Ok, took me some time but I have an answer for you. The cin and cout are standard inputs and outputs but they can't handle wide characters. Wide characters are special characters generally used by another language, like Chinese characters which need more then 8 bits. A standard character is 8 bits. So when you cin, you are reading it in regards to 8 bits so you need something that will read characters as 16 bits instead, which is where wcin comes in.
You don't HAVE to use wcin, but it is better in regards to universality. Generally an english based windows won't ever have to worry about it though. Personally, I use cin since you can easily change code from char to WCHAR (I have a conversion.h that I wrote that automatically does this when I want to write code for UNICODE, I also have for my major headers
1 2 3 4 5
|
#ifndef _UNICODE
hWnd = CreateWindow(chartoWCHAR(Title), chartoWCHAR(Title), .....
#else
hWnd = Createwindow(Title, Title, .....
#endif
|
As you can see here, this code was made to be used for UNICODE and non UNICODE which is generally what I write in. If you are more concerned with program size and are not going to worry about cross-language compatibility, then you should do the same as me and not use WCHAR or UNICODE. If you want to upgrade to support other languages, you must use UNICODE.
By the way, I assume most people post here already used google and either are confused with the responses they get or don't find what they need. This forum I believe (correct me if I am wrong) is tailored to getting a direct answer on C++ without all that hassle. Even though I haven't had to ask any questions here yet, I am always glad to help people where needed, tutoring or answering questions, in an effort to help people understand C/C++ better. So don't worry about the google response, you will never get it from me.
I may suggest reading up on certain topics to better understand them because sometimes the books can better explain something then me, but I will always direct you where you should go. Answering with google it to me is a waste of time because if no one answers then you would be forced to rely on google anyways which is not 100% guaranteed to help you.
The only reason I don't ask people to send me an e-mail with their questions is because those who are searching for answers can easily find answers here once they been answered. Now that your question is answered (to the best of my knowledge, someone may come along and better answer it after me), anyone who has the same question could learn from it much faster now that there is documentation on an answer and learn from it. I don't mind people messaging me for questions, but I like forums better because the help is more toward everyone rather then just one person.
Also, if someone told you to google it, most likely someone like me will tell them something they wouldn't want to hear and answer it for you anyways. I haven't been on this forum long but I have noticed there are quite a few people knowledgeable that seem to enjoy helping people. It is why I joined, also I too like hepling and guiding people. Are philosophies may not always agree but we share the same love for C\C++ and our desire to help people grow in the understanding of it.
As for your ProcessID, here is some code that may help that Mackabee posted
http://www.cplusplus.com/forum/windows/12137/
His code is great, but there is a cin version which I will put here but I wanted him having credit for his code because I based what I did on it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include <iostream>
#include <string>
#include <windows.h>
using std::string;
using std::getline;
using std::cout;
using std::endl;
int main()
{
string windowName;
getline(std::cin, windowName);
HWND windowHandle = FindWindowW(NULL, windowName.c_str());
DWORD* processID = new DWORD;
GetWindowThreadProcessId(windowHandle, processID);
cout << "Process ID of " << windowName.c_str() << L" is: " << *processID << endl;
system("PAUSE");
}
|
If you ran this code, it will also work unless you try to run it on Windows 7 Chinese version or some other language that has language characters that are too long for the standard char.