|
Not sure this will help but I would try:
IntPtr iPtr = Marshal::StringToHGlobalUni(s);
const wchar_t* chars = (const wchar_t*)iPtr.ToPointer();
os = chars;
Marshal::FreeHGlobal(iPtr);
MODIFIED: Keep in mind I am really confused since your initial post makes no mention of managed memory and does not seem to match at all what you have put in your last post.
led mike
|
|
|
|
|
Ugh, please excuse me... I am a moron. I copy+pasted the additional library directories from the debug to the release version, so it's picking up the debug versions of the libraries.
Just out of interest, would you tend to pass strings as parameters by std::wstring or wchar_t*? Is there a performance hit either way?
Thanks for your patience!
|
|
|
|
|
Raeldor_ wrote: would you tend to pass strings as parameters by std::wstring or wchar_t*?
Well for an "output" parameter wchar_t* is not going to work. For input parameter you could overload:
void MarshalString(std::wstring& is)
{
MarshalString( is.c_str());
}
void MarshalString(wchar_t* pis)
{
}
NOTE: std::wstring& is a "reference" which does not have any performance penalties compared with wchar_t*.... however std::wstring will copy the string data onto the stack.
void MarshalString(std::wstring& is)
is not equal to
void MarshalString(std::wstring is)
led mike
|
|
|
|
|
I always initialize variables by habit from C/C++ programming.
So in managed C++ I'll do this:
Int32 MyInt32 = 0;
I was told this is redundant. Is that true? And if so I would sure like to know where
in the documentation it states that value type are initialized to 0 - for peace of mind.
Until I see it I'll live with redundancy
Mark
|
|
|
|
|
Mark Salsbery wrote: I was told this is redundant.
While technically it is true that is not a reason to discontinue a "good practice" IMHO.
led mike
|
|
|
|
|
Thanks led mike.
Do you happen to know where it's documented? I can't find it anywhere!
Mark
|
|
|
|
|
Probably arises from this: Do not initialize unnecessarily[^]
However, it also explicitly states: "This rule ignores Managed C++ assemblies."
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
How can I get the DNS IP address that the local client is using?
Like to find a way using c++ and not MFC
thanX
|
|
|
|
|
Hi,
I am trying to wrap my C++ objects in a managed wrapper. I have...
public ref class MCamera
{
private:
NW::Camera* m_camera;
public:
MCamera(MNW::Vector3 in_source, MNW::Vector3 in_target, float in_near, float in_far, int in_outputWidth, int in_outputHeight);
~MCamera();
IntPtr GetCameraPtr();
};
and I'm putting a breakpoint on the code for the destructor but it never gets called. I've enabled unmanaged debugging and other breakpoints work, but it seems this never gets called. Does anyone know why the destructor is not getting called, even when the application is closed?
Thanks!
|
|
|
|
|
|
I HAVE TO write a programm that can erease all data from hard drive
that no one can recover it again.There are planty of algorithms that can do
that and I wanna use them in my programm.I have to write it for my exam pro
ject at university. Any help?? PLIZ...sorry for my English couse i`m not Pol
ish.
|
|
|
|
|
zetkonrad wrote: I HAVE TO write a programm that can erease all data from hard drive
that no one can recover it again.
And it needs to be in managed C++ ?
zetkonrad wrote: There are planty of algorithms that can do that and I wanna use them in my programm
OK, if you know the algorithms, why not use them ?
zetkonrad wrote: I have to write it for my exam project at university
OK, good luck doing your project. If you get stuck while working on it ( as oppossed to before you do any work ), by all means, ask specific questions in the correct forum, and we would love to help you.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi there,
I need to build an optimized circular buffer of variabe length messages in C++. The elements are std::string types and I can dedicate a fixed amount of space to this log, in the sense that I can preallocate a memory block of fixed size and work in there. Can anybody indicate me some examples or techniques in C++ (in fact it should run under Linux) to do this ?
Thanks for your help
Marco
marcof
|
|
|
|
|
this is a managed C++ forum, try the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all,
I am beginner in C++.Just want to know whether we can use only c++ to preodeuce a program.
|
|
|
|
|
You can use any language you like, there are hundreds.
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
This is the managed C++ forum. I think you wanted the Visual C++ forum.
You can write a program using only C++ if you want to. But, as someone said, you can use lots of other languages, too. Realistically, the languages most used on a PC are C, C++, C#, VB6 and VB.NET.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Could anyone please, answer this question for me
Is it necessary to create a constructor when you are dealing with things like mathematical formulae that involves using classes?
Thanks for your prompt response.
Regards,
SKG!
skg
|
|
|
|
|
I doubt this is a managed C++ question.
What makes you think it would be necessary ? You get a default constructor for free, you can hide that by making it private, and you can add any sort of constructor you want. If you want to pass anything to the constructor, you need to write one. If you have any pointers or variables that need to be initialised ( which seems likely ) then you need a constructor to do that. But the fact that you're doing mathematical operations is of itself irrelevant, what matters is the needs of the specific class.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I added a UserControl -derived custom control to the my application's project. Is there a possibility for this control to show up in the Toolbox? I would like to make it available for multiple forms in the same project.
When I try to import the MyApp.exe into the Toolbox (via Choose Items...), it says:
Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)
I suspect I will need to move the control code into the DLL, am I right? Or maybe there is some trick to keep it in the main image?
|
|
|
|
|
My company is moving from Native C++ to .Net C++. We are not switching out all our code. New developments will be done in CLR and C#.
I want to perform my new development as a CLR managed Class Library. (I have several requirements that force me not to use an unmanaged Class Library.) HOWEVER, my software lead is worried that my managed Class Library .dll will be used by our competition.
My question is, “Is he right?” Can my code be stolen and used since the .dll will need to be released with the main application?
Thanks
Glenn
|
|
|
|
|
earlgraham wrote: My question is, “Is he right?” Can my code be stolen and used since the .dll will need to be released with the main application?
Any dll can be used by your opposition. Just as you can p/invoke to call Win32 APIs in C#, or use LoadLibrary to use an API that you don't have the headers for, the only issue is discovery of the methods available from a dll, unless you have some sort of protection in place ( such as passing a token which acts as a password ).
.NET code can, by definition, be decompiled, which increases your exposure for sure. There are measures you can take, such as obsfucation, but you can't stop it. And, of course, decompilation means that any security measures you take can be circumvented.
Having said that, if they use your dll directly, you'd find out about it. If they stole your code, that would be harder, but if you write good, small methods, obsfucated code may be painful to use in that way.
The real question is, how far do you have to go to stop it being worth their while, how unique/difficult/valuable is the code in question ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks. I was afraid if this. It would have helped a lot if I could have worked it out.
Thanks again
Glenn
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
Sorry - it's the one big issue with .NET, obsfucation does help, but the really solid libraries in this regard also cost a bomb.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all,
In VS2005, I'm trying to debug a C++ dll, called from a tiny VB test app - but when I 'Go' (F5), my breakpoints are disabled - the Output window tells me No symbols loaded for my Interop.fubar.dll (where fubar is my dll name) -
I've built the dll with Debug options - Is there something else I have to tell VS2005 to load its symbols??
thanx!
~ Mike
|
|
|
|