[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::visualc

Title:Microsoft Visual C/C++
Moderator:PLUGH::needle
Created:Tue Mar 16 1993
Last Modified:Wed Jun 04 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1121
Total number of notes:4385

1090.0. "A2W + W2A convenience routines for Unicode" by BIGUN::nessus.cao.dec.com::Mayne (Churchill's black dog) Fri Feb 28 1997 00:23

I'm writing a console application (see below) to return user information. (I'm 
doing it a console app just to get the code right; I'll do it in a larger DLL 
later.)

I user GetUserName to get the username, and then NetUserGetInfo to get other 
stuff. Trouble is, NetUserGetInfo wants a Unicode username.

So, I'll use the convenience macros in TN059 to convert the normal one byte 
characters returned by GetUserName to Unicode. After hunting around (since TN059 
doesn't mention where they are), I discover them in afxpriv.h, so I include that 
and change the project settings to use MFC.

However, when I build this I get an error at line 577 of \MFC\include\afxpriv.h: 
"'CControlBar': base class undefined".

How can I use the A2W (and W2A) convenience routine?

I could do it laboriously, but as the TN says, it's easier to use the 
convenience routines, but why do I get this error?

Alternatively, can I avoid NetUserGetInfo? (I'll go looking some more.)

PJDM

#include <iostream.h>
#include <afxwin.h>
#include <afxpriv.h>
#include <lmaccess.h>

int main(int argc, char *argv[])
{
	cout << "User details" << endl;

	char username[80];
	DWORD usernamelen = 80;

	BOOL b = GetUserName (username, &usernamelen);
	cout << username << " (length " << usernamelen << ")" << endl;

	USER_INFO_10 *pUi;
	NET_API_STATUS s;
	USES_CONVERSION;
	s = NetUserGetInfo (NULL, A2W (username), 10, (LPBYTE *)&pUi);
  
	cout << "NUGI = " << s << endl;
	cout << W2A (pUi->usri10_full_name) << endl;

	return 0;
}
T.RTitleUserPersonal
Name
DateLines
1090.1BIGUN::nessus.cao.dec.com::MayneChurchill&#039;s black dogFri Feb 28 1997 00:478
Almost immediately I found Q119670, "How to Look Up a User's Full Name", which 
does the job, but it would still be nice to know how to use A2W and W2A.

BTW I had to search the libraries with FIND to figure out which one to link 
against to get NetUserGetInfo. Given a function name (e.g. NetUserGetInfo), 
what's the quickest way of finding out what to link with to get it?

PJDM