|
-
Feb 26th, 2001, 12:01 PM
#1
Thread Starter
Member
does anyone know how to get the computer name from the network properties?
-
Feb 26th, 2001, 12:48 PM
#2
Frenzied Member
Code:
#include <windows.h>
#include <iostream.h>
char *buffer = new TCHAR[256];
DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
GetComputerName(buffer,&len);
//buffer contains computer name
cout<<buffer<<endl;
-
Feb 26th, 2001, 01:10 PM
#3
Monday Morning Lunatic
Change this:
char *buffer = new TCHAR[256];
to this:
TCHAR *buffer = new TCHAR[MAX_COMPUTERNAME_LENGTH];
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 26th, 2001, 01:59 PM
#4
Frenzied Member
Ah , thans Parksie. I put the MAX_COMPUTERNAME_LENGTH in the code later so i forgot to change it in the buffer declaration.
-
Feb 27th, 2001, 03:19 PM
#5
Thread Starter
Member
Well the first one worked why the change?
Thanks again..
-
Feb 27th, 2001, 03:24 PM
#6
Monday Morning Lunatic
Okay...normally TCHAR resolves to char. However, if you compile for Unicode it resolves to wchar_t, which is two bytes. So, normally it's fine.
That's the obscure one gone... 
The other change was just to match the buffer sizes.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|