I'm trying to get a players name from a file on their computer and then display that name onto a Label on my chat program. This Label is also used when sending messages to the server in order to display the persons name with their message.
The problem I'm having is that when I read the file and display the contents its adding random symbols to the contents and taking away parts of the word...
Here is the code I'm using...
// Player's Name
HANDLE hFile;
DWORD wmWritten;
char strName[20];
hFile = CreateFile("C:\\ZacarasEmpire-Offline\\Data\\File01.ze",GENERIC_READ,
FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
int NameSize = sizeof(hFile);
ReadFile(hFile,strName,NameSize,&wmWritten,NULL);
CloseHandle(hFile);
hEditName = CreateWindow(TEXT("STATIC"), strName,
WS_CHILD | WS_VISIBLE | SS_LEFT,
40, 190, 100, 23,
hWnd, (HMENU) IDC_EDIT_NAME, GetModuleHandle(NULL), NULL);
So this turns strName into whatever is written in File01.ze (which is the players name) and then displays strName into the Name label on the screen.
File01.ze currently has just the word Ertzel written in it and nothing else. This is what I need displayed. If you look at the attached picture, thats what is being displayed instead of the word Ertzel.
I can't figure out why its not displaying the correct text onto the label....