AssafLavie
asked on
How to retrieve domain name?
(Really easy question...)
How do I programmatically retrieve the Domain name for the computer on NT and 95?
How do I programmatically retrieve the Domain name for the computer on NT and 95?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
JKR's answer is better.
Thanks, JKR, but the points should go to jhance for answering first.
Thanks both.
Thanks, JKR, but the points should go to jhance for answering first.
Thanks both.
>>but the points should go to jhance for answering first.
I wouldn't mind that if his suggestion was something similar...
Usually you grade people whose answer you actually are going to use :o(
I wouldn't mind that if his suggestion was something similar...
Usually you grade people whose answer you actually are going to use :o(
Well, if we're critcizing answers here, I'll just point out that the getenv() method has the potential to return an incorrect value. If the user or some program changes the USERDOMAIN environment variable, it will no longer reflect the correct domain name.
A further problem is that this feature may change without warning in a future version of Windows and so your program might break.
If possible, use the Windows API to get what you need. Other methods may be used at your own risk...
A further problem is that this feature may change without warning in a future version of Windows and so your program might break.
If possible, use the Windows API to get what you need. Other methods may be used at your own risk...
>>Well, if we're critcizing answers here
I wasn't about to critizise your answer, jhance - I only wanted to point out that, when two very different approaches are suggested, it doesn't make sense to grade after the order in which they were submitted, especially if one is going to use the latter one...
I wasn't about to critizise your answer, jhance - I only wanted to point out that, when two very different approaches are suggested, it doesn't make sense to grade after the order in which they were submitted, especially if one is going to use the latter one...
#include <stdlib.h>
char* pszDomain = getenv ( "USERDOMAIN");