Hi,
How do I get a the current user's home directory
within a program, on Windows2000. The following code
which works on NT fails in Windows2000 which uses
Active Directory to retrieve directory information...
It returns the HOMEDRIVE instead of HOME.
Any help in this is welcome.
Here is the code.
Thanks
Anand
#define MAXSTR 1024
define RET_STRING_SIZE 256
get_nt_user_home(char* user_home)
{
int size=MAXSTR;
WCHAR wuser_name[MAXSTR];
USER_INFO_1 *user_info;
if( GetUserName( user_name, &size ) )
{
MultiByteToWideChar( CP_ACP, 0, user_name, size,
wuser_name, sizeof(wuser_name ) );
{
status = NetUserGetInfo( NULL,
wuser_name, 1,
(LPBYTE *)&user_info);
if( status == NERR_Success )
{
WideCharToMultiByte( CP_ACP, 0,
user_info->usri1_home_dir, wcslen( user_info->usri1_home_dir, user_home, RET_STRING_SIZE, "\0", NULL );
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mail me at abpillai@excite.com if you want additional help. I dont promise that I can solve your problem, but I will try my best.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~