And I want to use classical function
BOOL SetCurrentDirectory(
LPCTSTR lpPathName // new directory name
);
Now if I put variable sa as argument I get an error...
c:\Besedila\Visual Studio Projects\C\Razno\Pretvordbe besed\Pretvordbe
besed.cpp(42): error C2664: 'SetCurrentDirectoryW' : cannot convert
parameter 1 from 'System::String __gc *' to 'LPCWSTR'
So how I convert System::String to LPCWSTR?
Anton, ml.
P.S. Please don't ask why I need this and I am quite sure that micro
and soft created a function and there "must" be a simple normal way to
convert it to "normal" string in C/C++, but I can't find it in help
files...
In many implementations there is a "char const *" wtich
wil work for a LPCSTR. It looks like your code wants a
wide (unicode) char pointer, depending on the
implementation of the string class, this may not be
available.
Sorry that I don't jhave a magic bullet, but this IS one
of the issues ofr going from a raw to manager environment,
be it either C to C++ or C++ to .NET.
David.
>.
>
In this particular case, it's not a char*, it's a char const *, so it's
not allowed to be modified. Hence, the safety issue should not be
a problem.
The more likely issue is conversion from ANSI to UNICODE. I would
expect (and might very well be wrong) that System::String has either
a default conversion or accessor function for LPCSTR, but a conversion
to unicode will still be required.
Alternatively, the OP could just call SetCurrentDirectoryA instead of
SetCurrentDirectoryW.
I'm curious why LPCTSTR is resolving to wchar_t, so you have #defined
_UNICODE, but String is constructing a char buffer. You didn't show the code
that allocates the System::String object. That's about all I can say since I
know nothing about.NET, maybe try the .NET newsgroup. Did you try the
ToCharArray() function? check the documentation on System::String in MSDN
John
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q311259
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"Anton" <vah...@email.si> wrote in message
news:8ebfff67.02022...@posting.google.com...