Solved

'UuidToStringW' and 'RpcStringFreeW'  errors..

Posted on 2009-07-11
7
1,779 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need some help with mailto 16 40
what type of pointer is this pointer? 3 29
maximize the sum of fractions 33 70
listing all the respondents to a twitter feed - Java 5 41
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
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.
Suggested Courses

738 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