Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2005

Tip: Looking for answers? Try searching our database.

Newbie question regarding data type casts.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anthony Yott - 31 Oct 2005 19:25 GMT
Folks,

I've inherited some C++ code that I'm trying to convert from VC++ 6.0 to
VC++ 2005 and was wondering if anyone could help as I haven't done any C++
programming in several years.

The code is basically trying to populate a struct that is defined in the
sspi.h file. The compile error that I'm getting is "error C2440:
'initializing' cannot convert from wchar_t* to unsigned short*".

Here is the code to populate the struct:

const wchar_t* pszAuthority
const wchar_t* pszPrincipal
const wchar_t* pszPassword

SEC_WINNT_AUTH_IDENTITY_EX authIdent = {
       SEC_WINNT_AUTH_IDENTITY_VERSION,
       sizeof authIdent,
       const_cast<wchar_t*>(pszPrincipal), //*****Compilie error here******
       lstrlenW(pszPrincipal),
       const_cast<wchar_t*>(pszAuthority), //*****Compilie error here******
       lstrlenW(pszAuthority),
       const_cast<wchar_t*>(pszPassword),  //*****Compilie error here*****
       lstrlenW(pszPassword),
       SEC_WINNT_AUTH_IDENTITY_UNICODE,
       0,
       0};

The struct is defined as follows in the sspi.h header file

#define SEC_WINNT_AUTH_IDENTITY_EX  SEC_WINNT_AUTH_IDENTITY_EXW

typedef struct _SEC_WINNT_AUTH_IDENTITY_EXW {
   unsigned long Version;
   unsigned long Length;
   unsigned short SEC_FAR *User;
   unsigned long UserLength;
   unsigned short SEC_FAR *Domain;
   unsigned long DomainLength;
   unsigned short SEC_FAR *Password;
   unsigned long PasswordLength;
   unsigned long Flags;
   unsigned short SEC_FAR * PackageList;
   unsigned long PackageListLength;
} SEC_WINNT_AUTH_IDENTITY_EXW, *PSEC_WINNT_AUTH_IDENTITY_EXW;

I guess the question is what is the best way to "cast" a wchar_t* to a
unsigned short* so that it will compile and run correctly? Any help or
feedback would be greatly appreciated.

Signature

Anthony Yott

Jochen Kalmbach [MVP] - 31 Oct 2005 19:43 GMT
Hi Anthony!

Already answerd in "microsoft.public.vc.language"... (either switch to
/Zc:wchart_t- or do a reinterpret_cast)

Signature

Greetings
  Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.