Solved

'UuidToStringW' and 'RpcStringFreeW'  errors..

Posted on 2009-07-11
7
1,751 Views
Last Modified: 2013-12-21
I'm trying to use CoCreateGuid to generate a GUID in my VC++ windows mobile project.
The following code:
GUID guid;
 CoCreateGuid(&guid);
BYTE * str;
 UuidToString((UUID*)&guid, &str);
 CString unique((LPTSTR)str);
 RpcStringFree(&str);
unique.Replace(_T("-"), _T("_"));

gives me the following errors:
error C2664: 'UuidToStringW' : cannot convert parameter 2 from 'BYTE **' to 'unsigned short **'
error C2664: 'RpcStringFreeW' : cannot convert parameter 1 from 'BYTE **' to 'unsigned short **'

how do i solve this?
0
Comment
Question by:Wanting2LearnMan
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 12

Accepted Solution

by:
Gideon7 earned 167 total points
ID: 24831211
Windows Mobile always uses UNICODE mode (there are no ANSI APIs for UuidToString, etc).   Change str from BYTE* to RPC_WSTR.
 
0
 
LVL 24

Assisted Solution

by:alexey_gusev
alexey_gusev earned 167 total points
ID: 24831214
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 166 total points
ID: 24831218
Try an explicit cast, e.g.
GUID guid;

 CoCreateGuid(&guid);

BYTE * str;

 UuidToString((UUID*)&guid, (LPTSTR*)&str);

 CString unique((LPTSTR)str);

 RpcStringFree((LPTSTR*)&str);

unique.Replace(_T("-"), _T("_"));

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Wanting2LearnMan
ID: 24831274
>>use 'RPC_WSTR'
error C2065: 'RPC_WSTR' : undeclared identifier      

>>Try an explicit cast
same errors as original post

still looking into alexey_gusevs suggestion

0
 
LVL 12

Assisted Solution

by:Gideon7
Gideon7 earned 167 total points
ID: 24831284
Include <rpc.h>   UuidToString is odd in that it uses RPC_WSTR (unsigned short *) instead of LPWSTR (wchar_t *).
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 166 total points
ID: 24831289
Strange, should not happen... what about the following?
GUID guid;

 CoCreateGuid(&guid);

BYTE * str;

 UuidToString((UUID*)&guid, (unsigned short**)&str);

 CString unique((LPTSTR)str);

 RpcStringFree(((unsigned short**)&str);

unique.Replace(_T("-"), _T("_"));

Open in new window

0
 
LVL 24

Assisted Solution

by:alexey_gusev
alexey_gusev earned 167 total points
ID: 24831314
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now