|
Hi Guys,
Still fighting with some conversion problems.
Hope someone could help.
//some Typedefs.
typedef unsigned char T_Byte;
typedef std::basic_string<t_byte> T_ByteArray;
I want to convert the following value to a CString.
[1]
T_Byte LineFeed[] = {'\x0D','\x0A'};//Hexadecimal Values.
T_ByteArray valLineFeed;
valLineFeed.append(LineFeed,sizeof(LineFeed));
want to convert the "valLineFeed" to a Cstring so that it contains a string "0D0A".
How could I achieve that?
[2]
Same way,If some one gives me a string "0D0A",would want to convert it to a T_ByteArray which contains characters like '\x0D','\x0A'
In short,If someone gives me a string "0D0A".Want to insert the characters "\x" before "0D" & "0A" & make a T_Byte string
which is like :
T_Byte LineFeed[] = {'\x0D','\x0A'}
How Could I achieve this also..
Thanks in advance..........
|
|
|
|
|
Here is the problem with what you ask. Your questions pertain to fundamental C++ issues. There are books and web based tutorials containing pages that discuss in detail the topic you are asking about. Someone could post a simple code example that depicts what you are asking but that would not help you understand the how and why it works which is what you should be most interested in rather than just the code to do it.
It is unlikely that someone will write a specific message here explaining the topic when it is easily found on the net and in books.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
How can I convert String to unsigned char __gc[] and vice versa???
Anyone got an idea?
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
Managed String Objects can be initialized directly from unmanaged memory blocks. They will copy the memory for you.
To copy Managed memory into unmanaged memory blocks you need to Marshall the unmanaged memory using the System::Runtime::InteropServices::Marshal class.
Hate is not a family value.
-pete
|
|
|
|
|
This may be the wrong place to ask but where else should I go?
I'm new to .Net and WebServices. However, I'm old in programming MFC/C++ and Java.
I would like to write a WebService (Server) which is NOT running within a IIS (ASP). All I need is a normal managed Windows Service which is listening on a spec. port to publish it's WebService interface. However, there are lots of examples on how to write WebServices using ASP.Net but it seams tobe impossible to accomplish the same with a 'normal' EXE.
Please don't ignore me, let me know your opinion....
Cheers
Christian
|
|
|
|
|
Hi Guys,
Going mad with this....
I have a string object say,
String val("Context");
How Can I convert this "val" to a CString.
Tried as follows,but didn't work
CString test;
test.Format(_T("%s"),val.c_str());
It gave me junk value.....
Any help is appreciated....
|
|
|
|
|
Your first post you asked about "wstring to LPCTSTR"
Now you ask about "String to CString" then your code attempts to use a wstring function "c_str()" on a type "String". Assuming you posted your code correctly you should have received a compile error which you did not post.
Perhaps someone else can divine exactly what you are attempting to do and provide you with an answer. I however require accurate specific and complete information regarding this problem before I can begin to help.
Furthermore there is no shortage of articles on the net pertaining to the variety of string types in VC++ and matters of converting between types. If you care to see what I mean just Google [MSDN CString Strings LPCTSTR TCHAR]
I highly recommend studying this subject, it will payoff huge in terms of productivity and will ease your development efforts greatly.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Did itg as follows 6 worked
void C_MappedTrgtFieldTab::ConvertToString(T_String & val,CString &targetVal)
{
string Target;
FromString(val,Target);
targetVal= Target.c_str();
}
Thanks anyway..
|
|
|
|
|
Hi,
How Can I convert a wstring to LPCTSTR.
I have a unicode setting for my project...
Thanks in advance...
|
|
|
|
|
Hi,
I need to wrap a native c++ class which has a virtual function this virtual function needed to be implemented with the derived classes from this class(the function is called automatically like events from the class), how can i do that using c++/cli??
thx
|
|
|
|
|
Hi, I am using managed c++ to (try) and get a project that will go through a directory of files and copy them to two directories if the contents are right. Currently the sorting goes alright, but not if I insert the copy call, well, I get this runtime error:
System.IO.IOException: The target directory already exists.
First of all, I'm hoping the directory exists... I have the code write out what it's copying from and to using Console::WriteLine, and I can assure you it is valid and proper. I tried using the overload that includes the boolean and set the boolean to true to allow it to override the file, but it still insists the directory exists.
Has anyone else noticed this and/or got a solution?
|
|
|
|
|
I feel like an idiot now
I changed the code BEFORE the call, but I didn't change the call itself to use the new variable. Now it works fine. PEBKAC right here, I'll tell ya.
|
|
|
|
|
How do I DeSerialize a file in C++ .NET (e.g. using BinaryFormatter) that was originally created by Serialized in an MFC appliction using CDocument::Serialize?
When trying to do this, I get:
BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 1684632134.539785569.
Thanks!
|
|
|
|
|
I want to setup hotkeys in my application to control vobsub to show ,hide or shift the subtitles for DivX video becuase the VobSub doesn't offer this service and it's not convenient to control it by mouse. As I know ,usual hotkey software use hook tech to implement such function, but I don't know VobSub's interface and don't know how to get it. I need your help!
|
|
|
|
|
Hi,
I have 3 projects:
"Managed C#" calling "C++ Managed Extension (mixed code)" calling "Unmanaged C++ code"
I am trying to debug them using .Net Visual Studio 2003, setting breakpoints on each project. Unfortunately, it is not able to trace down to unmanaged code.
There are some exceptions happening in unmanaged code - and I cant proceed further with the project unless I am able to debug them to know what's going on.
Has anyone come across this situation before??
cheers,
nics
|
|
|
|
|
Hi
I am in the process of upgrading an older program written using MCF.
Some parts of the new program use Managed C++ and Windows.Forms (external dll).
Is there an easy way of integrating the two - for example press a .NET button (e.g. of type System::Windows::Forms::ToolBarButton) to open a MFC dialog (of type CDialog)?
I don't want to rewrite everything as Windows.Forms (e.g. convert "CDialog" to "System::Windows::Forms::Form")
|
|
|
|
|
We are also trying to do the same and want to reuse the document view architure in one of the complex component. How do we do that? Can we make .NET form as Mainframe/ChildFrame for the views and document? Any pointers will be appreciated.
Thanks.
|
|
|
|
|
;PHi,
I can solve your problem, if you have any questions about use .Net Control in your MFC Project, please contact me, my e-mail is sunhui@mail.apptemplate.com, please visit my site: http://www.apptemplate.com
sunhui
|
|
|
|
|
Hi,
I can solve your problem, if you have any questions about use .Net Control in your MFC Project, please contact me, my e-mail is sunhui@mail.apptemplate.com, please visit my site: http://www.apptemplate.com
sunhui
|
|
|
|
|
Have been trying without success to call an managed function from
within an unmanaged class. This would seem to be a basic requirement,
of the dotnet so I am obviously doing something wrong.
Given the class CMyManaged header as:
#pragma once
public __gc class CMyManaged
{
public:
CMyManaged(void);
~CMyManaged(void);
void MyFun(void);
};
and a standard MFC dialog class, I wish to call MyFun() from
within MyMFCDlg().
Now I went about this by declaring a CMyManaged variable m_MyManaged;
in the unmanaged MyMFCDlg() header file. Then in MyMFCDlg.OnInitDialog()
I try to call m_MyManaged.MyFun();
Have tried declaring the managed variable as
gcroot<cmymanaged*> m_MyManaged;
But various means to call MyFun() have all resulted in
compilation errors.
Any help would be appreciated, as the C# dialog box is to limited I
need to continue developing partially in Unmanaged C++.
Many thanks
|
|
|
|
|
3green wrote:
have all resulted in
compilation errors.
Post the compiler error messages, otherwise we have to guess.
Obvious things to check:
Do you have properly configured "mixed mode" project settings?
Do you have required #include and import statements?
If you don't know what one or both of those are you need to use MSDN to read about "mixed mode" development.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi,
My current Project has the following Requirements:
1. Backup the entire contents of the hard disk including Operating System as a bootable Image.
2. In case of System Failure, user should be able to perform a full system-recovery operation using the Backed up Image of the Hard Disk.
I am new to this concept and request any sort of help on how to proceed with this.
Any help will be greatly appreciated..
Regards
-Ram
|
|
|
|
|
That is generally considered too broad a subject or too vague of a question to receive a meaningful reply in a forum. You could probably write a book chapter or several on a subject of that scope. You might have to do some reading until you have broken down your problem into it's constituent parts. The post small specific questions to obtain help in a forum format.
But, that's just my opinion... I could be wrong.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
|
Okay, I'm a little confused. So, the ANSI / ISO Standard C++ is
a stardard C++ lanugage that targets non .Net platform and
managed C++ is designed by Microsoft that targets .Net platform.
Code that generated by using the ANSI C++ is also called native code or unmanaged code
and code that generated by using Manage C++ is called managed code.
Is that right?
|
|
|
|