473,320 Members | 1,945 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,320 software developers and data experts.

question about System.String, CString, PCSTR, etc, etc

Trying to wrap an unmanaged class.
Here is the function I'm trying to wrap:
bool Init(PCSTR filename, PCSTR username, PCSTR password, PCSTR working);
In my managed C++ class, I have a method like this:
bool CSUSSWrapper::Init(String* filename, String* username, String*
password, String* working)

{

CString _filename(filename);

CString _username(username);

CString _password(password);

CString _working(working);

return m_objSourceSafe.Init((PCSTR)_filename, (PCSTR)_username,
(PCSTR)_password, (PCSTR)_working);

}

Now that seems really ugly and probably not necessary. It compiles and it
works, but it's UGLY. Is there a cleaner way?

THanks,
Steve

Nov 17 '05 #1
1 3817
actually this doesn't work ;(

"SteveK" <as***@asdfasdfsd.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
Trying to wrap an unmanaged class.
Here is the function I'm trying to wrap:
bool Init(PCSTR filename, PCSTR username, PCSTR password, PCSTR working);
In my managed C++ class, I have a method like this:
bool CSUSSWrapper::Init(String* filename, String* username, String*
password, String* working)

{

CString _filename(filename);

CString _username(username);

CString _password(password);

CString _working(working);

return m_objSourceSafe.Init((PCSTR)_filename, (PCSTR)_username,
(PCSTR)_password, (PCSTR)_working);

}

Now that seems really ugly and probably not necessary. It compiles and it
works, but it's UGLY. Is there a cleaner way?

THanks,
Steve

Nov 17 '05 #2

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

Similar topics

7
by: Herman | last post by:
Hi everyone, I recently installed the Sun J2SE SDK on my machine, and I am having trouble running the java.exe interpreter for my Java compiled code. I remember that I had to set my environment...
3
by: Terry chan | last post by:
Hi, How to convert String object to MFC CString? and from CString to String? Thanks! chan
23
by: YinTat | last post by:
Hi, I learned C++ recently and I made a string class. A code example is this: class CString { public: inline CString(const char *rhs) { m_size = strlen(rhs);
2
by: mirek | last post by:
Hi, I'm trying to import my old code to the .NET using managed wrappers. I've read "Managed Extensions for C++ Migration Guide" document and was trying to do what it stated in it. For example if...
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
1
by: Klynt | last post by:
Project built using /CLR, but code is old and has not been converted specifically to "managed" (__gc or __value). Everything seemed to work great, until I got the following error. I have a...
8
by: Tony H | last post by:
Is there a way to read an MFC serialized class containing CStrings, ints, and doubles using a CLR-based class? Specifically, to get CString into System::String? Bye the Bye, is System:: String...
10
by: Herby | last post by:
I seem to be having a problem with System namespace. There seem to two System namepaces when viewing through Object browser within .NET 2005. One global System:: Then one under <mscorlib> Each...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.