Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

'UuidToStringW' and 'RpcStringFreeW'  errors..

Posted on 2009-07-11
7
Medium Priority
?
1,867 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 668 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 668 total points
ID: 24831214
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 664 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 668 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 664 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 668 total points
ID: 24831314
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

877 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