-2

I received an error - In Delphi XE3 - using chilkat library . This is the error:

[dcc32 Error] Unit3.pas(79): E2010 Incompatible types: 'PWideChar' and 'WideString'

and this is a piece of my code that received this error :

var  
 privKeyXml: PWideChar;  
...  
 privKeyXml := rsa.ExportPrivateKey();   
...  

The ((ExportPrivateKey)) will Export the key in XML format ( As I read in the chilkat website ) How can I fix it ?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Arshia
  • 27
  • 6
  • 1
    You've provided one line of code, totally out of context, with no information that is needed to answer. What type is `privKeyXML`, and what type does `rsa.ExportPrivateKey` return? I suspect that once you figure that out, you'll solve the question yourself. – Ken White Feb 03 '16 at 19:04
  • Take a step back. Do you want us to solve this problem, or do you want to learn how to do it? The correct answer is of course the latter. So, do you understand what the compiler error means? – David Heffernan Feb 03 '16 at 19:08
  • 1
    Well, you provided **exactly half** of the information I asked you to provide. Can you now **provide the other half**? – Ken White Feb 03 '16 at 19:11

1 Answers1

0

ExportPrivateKey() returns a WideString value:

TChilkatRsa Delphi ActiveX Reference Documentation

function ExportPrivateKey(): WideString;

You can't assign a WideString to a PWideChar directly, you need to type-cast it, eg:

var  
 privKeyXml: WideString;  
 privKeyXmlPtr: PWideChar;  
...  
 privKeyXml := rsa.ExportPrivateKey();   
 privKeyXmlPtr := PWideChar(privKeyXml);
...  
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770