![]() |
Computer name w/C++
Hey guys,
I have a little program i created using c++. All the program does is runs a dxdiag on the local machine, then outputs the results in a .xml file on the desktop. Then code looks like this: :
#include <iostream>I need to save the file to a folder on a server with the computer name as the file name. Is there any way to find the computer name with c++? |
Hmm here is an interesting idea, why not have a look on Google? Or better yet look at the Win32 api docs!
I will save you the effort (hardly any really). In windows.h you will find an interestingly named function called GetComputerNameEx(…). I wonder what that could do? You can look up the parameters yourself using the Win32 documentation on MSDN or your local copy of the docs either in a Platform/Windows SDK or MSDN distribution. |
You can also use the COMPUTERNAME environment variable to get your name. Call GetEnvironmentVariable(...):
:
DWORD WINAPI GetEnvironmentVariable(and use the return value in your program. |
@Random-Spirit -- Here is another interesting idea...thank you for the help, but if you dont feel like responding, dont. I appreciate the help.
|
http://www.cplusplus.com/reference/c...ib/getenv.html
For Linux: :
#include <iostream>For Windows... the environment variable you want is "COMPUTERNAME". |
Got it! Thanks Guys.
|
| All times are GMT -5. The time now is 3:08 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC