473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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 3646

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Trep | last post by:
Hi there! I've been having a lot of difficult trying to figure out a way to convert a terminated char array to a system::string for use in Visual C++ .NET 2003. This is necessary because I...
3
by: Morten Overgaard | last post by:
Hi How do I convert a managed System::String to a CString. I need to handle unicode characters ( Japan and Chinese ) as well as "normal" ANSI characters. I have tried the following char* p...
15
by: Yifan | last post by:
Hi Does anybody know how to convert System::String* to char*? I searched the System::String class members and did not find any. Thanks Yifan
2
by: Alper Akcayoz | last post by:
Hello Esteemed Developpers I would like to thank you in advance for your sincere responses I am a fresh Visual C++ .NET Developer. Can you kindly guide me for How to Convert char* to System::String
5
by: sarab | last post by:
Hi, I have a managed C++ app in which i need to convert String * to char *. How can i achive this?. regards -sarab
2
by: npverni | last post by:
I have a string with name value collections (i.e. &foo=1&foo2=2) Can I convert this string to some kind of name/value collection so I can access the values with something like : params = 1; ...
7
by: nicolas.hilaire | last post by:
hi all, i'm using this code to convert a String ^ in char * String ^str = "string .net"; IntPtr p = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str); LPCSTR str2 =...
2
by: sovarschizsuzsa | last post by:
Hy! I have written a MC++ wrapper DLL file for use in a C# project. This wrapper DLL is built on a C DLL. I have the following functions in the C DLL: int First(char* a1, char* a2, void* *a3,...
3
by: simon | last post by:
I am a fresh Visual C++ .NET Developer. Can you kindly guide me for How to Convert char to System::String I am using windows forms and trying to set a text value referencing the method...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.