Solved

'UuidToStringW' and 'RpcStringFreeW'  errors..

Posted on 2009-07-11
7
1,739 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
Comment Utility
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
Comment Utility
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 166 total points
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:Wanting2LearnMan
Comment Utility
>>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
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
typedef std::deque<BYTE> ByteVector is broken in vs2012 23 73
java ^ examples 8 57
Problem to event 3 47
Unable to start eclipse ? 17 82
Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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

10 Experts available now in Live!

Get 1:1 Help Now