Solved

'UuidToStringW' and 'RpcStringFreeW'  errors..

Posted on 2009-07-11
7
1,760 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reset Kindle Fire HD 7 2 122
MaxSpan challenge 9 96
Not needed 13 113
JQuery serialize and unserialize 8 87
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 …
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

803 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