469,267 Members | 1,225 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

PtrToStringChars Cannot convert unsigned char * to System::String *

Hi All,
I am new to this board. I am trying to create a Crystal Report viewer into a
VS C++ Dot NET 2003 app ( This uses both managed and unmanaged code).

I get the following compilation error:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\
cstringt.h(875): error C2664: 'PtrToStringChars' : cannot convert parameter 1
from 'unsigned char *' to 'const System::String __gc *'

The code segemnt is:
#pragma once
#pragma managed
void CDailyRep::OnBnClickedNewreportsOk()
{
/************************************************** *******/

CrystalDecisions::CrystalReports::Engine::ReportDo cument * crReportDocument =
new ReportDocument();
// ReportDocument::FileName = "BATCH.RPT" ;
// ReportDocument::FilePath = "c:\\QpayReports_CR10\\" ;
crReportDocument->Load(L"C:\\QpayReports_CR10\\Batch.RPT",OpenRepor tMethod::
OpenReportByTempCopy);
// crReportDocument->Load(( System::String __gc*)L"c:\\QpayReports_CR10\\
BATCH.RPT"); // ,OpenReportMethod::OpenReportByTempCopy);
// crReportDocument->Load("c:\\QpayReports_CR10\\BATCH.RPT"); // ,
OpenReportMethod::OpenReportByTempCopy);
// crReportDocument->Load(reportDocument) ;

// char * file1 = "c:\\QpayReports_CR10\\BATCH.RPT";
// wchar_t *file1 = L"c:\\QpayReports_CR10\\BATCH.RPT";
// String* file = System::Runtime::InteropServices::Marshal.PtrToStr ingAnsi
(file1[0]);
// String* file = Marshal::PtrToStringAnsi("c:\\QpayReports_CR10\\BA TCH.RPT")
;
// String* file = Marshal::PtrToStringAnsi(file1);
// String *file = __gc new String(file1); // char *.
// String *file = __gc new String("c:\\QpayReports_CR10\\BATCH.RPT"); // char
*.

// String *file = __gc new String("c:\\QpayReports_CR10\\BATCH.RPT"); // char
*.
// String *file
// crReportDocument->Load((String *)file);
// crReportDocument->Load(__gc new String("c:\\QpayReports_CR10\\BATCH.RPT"))
;
// crReportDocument->Load((__wchar_t)L"c:\\QpayReports_CR10\\BATCH.RPT ");

My command lin ios :
/G7 /GA /I "C:\TUXEDO\include" /I "C:\Program Files\Common Files\Crystal
Decisions\2.5\managed" /AI "C:\Program Files\Common Files\Crystal Decisions\2.
5\managed\en" /AI ".\Release" /D "NDEBUG" /D "_DWIN32" /D "WIN32" /D
"_WINDOWS" /D "WINNT" /D "_AFXDLL" /D "_MBCS" /FD /MD /GS /J /Zc:wchar_t
/Yu"stdafx.h" /Fp".\Release/Qpay.pch" /Fo".\Release/" /Fd".\Release/vc7.0.
pbd" /W3 /nologo /c /Zi /clr /TP

No matter what i use, the agrument passed to PtrToStringChars is always an
unsigned char *. I am at the end of my wits can any one please help?
Thanks,
Madhu

Jan 7 '07 #1
0 3340

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Morten Overgaard | last post: by
15 posts views Thread by Yifan | last post: by
2 posts views Thread by Alper Akcayoz | last post: by
5 posts views Thread by sarab | last post: by
7 posts views Thread by nicolas.hilaire | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.