简体   繁体   中英

c++ Clarification with String manipulation

I am not a c++ developper and I need to convert some code to vb.net

I found this

_tcslwr_s

which I don't even know if it is a type or a function (method).It is used in:

    _bstr_t _rbstProcessName
    TCHAR* ptcProcessName = static_cast<TCHAR*>(_rbstProcessName);
    _tcslwr_s(ptcProcessName, _rbstProcessName.length() + 1);

I know that _tcslwr_s is from a #define in tchar.h , a VS frameWork system file.

I would apreciate a short explanation of what is a #define and, in this case, what is _tcslwr_s

Thanks a lot in advance!


Edit

With the help of the comments now I know what is a define. Serching the code I found that _tcslwr_s define _wcslwr_s . The only two lines with this in it are in string.h and are:

_Check_return_wat_ _CRTIMP errno_t __cdecl _wcslwr_s(_Inout_z_cap_(_SizeInWords) wchar_t * _Str, _In_ size_t _SizeInWords);
__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(errno_t, _wcslwr_s, _Deref_prepost_z_ wchar_t, _String)

At this point I can't read anything.. What I am suposed to do to know what is going on with my two strings from the beginning ( _rbstProcessName and ptcProcessName ) ?

Again, thanks for the help!

According to this MSDN http://msdn.microsoft.com/en-us/library/y889wzfw%28v=vs.100%29.aspx _tcslwr_s is a macro that maps to various functions for converting strings to lowercase depending on the definition of the _UNICODE (Unicode support for standard functions) and _MBCS (multibyte character support for standard functions) macros. The VB.Net equivalent would be the .ToLower() string method.

_Check_return_wat_ _CRTIMP errno_t __cdecl _wcslwr_s(_Inout_z_cap_(_SizeInWords) wchar_t * _Str, _In_ size_t _SizeInWords); is declaring a function called _wcslwr_s that takes a wchar_t * and size_t and returns an errno_t . Everything that start with an underscore (except for _Str and _SizeInWords ) is an attribute of the function. For example, __cdecl indicates that the C calling convention should be used (see http://msdn.microsoft.com/en-us/library/zkwh89ks(v=vs.80).aspx ), and _In_ indicates that the parameter is passed to the function.

In plain english, this function takes a string and the size of the string and returns an error code. Based on http://msdn.microsoft.com/en-us/library/y889wzfw(v=vs.80).aspx , this function appears to convert the provided string ( _Str ) to lowercase.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM