What these types below represent (what kind of data they store ) and how can I use them (declaration and assign of data)
- LPCSTR
- LPCTSTR
-LPCWSTR
And how can I show a MessageBox dialog in a MFC Application
And the last one, how can I use a DLL also created in C++ in a C++ Visual Application Can this application be made in C++ .Net, or it must be MFC like the DLL
Thanks.

Info about some types
Bernd VanSkiver
Not sure about the MFC specific questions but the datatypes are:
- LPCSTR - This is a constant ANSI char pointer. So its const char *
- LPCWSTR - This is a constant UNICODE char pointer. So const WCHAR *
- LPCTSTR is either a LPCSTR or a LPCWSTR depending on if its in a unicode application or not.
So LPCTSTR will probably be the best to use because it means you have less code rewrite in case you ever change between ANSI and UNICODE.
ArtusKG
The datatype question has already been answered. See http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=136608&SiteID=1
blahmoo64
MessageBox or MFC library's AfxMessageBox.
http://msdn.microsoft.com/library/default.asp url=/library/en-us/vclib/html/_MFC_AfxMessageBox.asp
Regards,
-chris
TnTico
They're all pointers to null terminated character strings of one sort or another. You use them much as you'd use a char * pointer or a wchar_t * pointer - e.g., with string functions like strlen_l, wstrlen_l, etc.
Documentation for these (and other) types can be found here http://msdn.microsoft.com/library/en-us/winprog/winprog/windows_data_types.asp.
'LPCSTR' stands for "Long Pointer to Constant STRing". 'LPCWSTR' stands for "Long Pointer to Constant Wide STRing" where 'Wide' in this case means UNICODE. 'LPCTSTR' stands for "Long Pointer to Constant T STRing". I have no idea what the "T' stands for but basically the 'T' character types are either narrow (mbcs) or wide(UNICODE) depending on whether the #UNICODE macro is defined.
The "Long Pointer" buit doesn't really mean much any more, it's a hold over from older memory models when some pointers were not 'long'. Constant means the 'const' keyword was used in defining the type so it isn't modifiable.
You can't really assign values to the contents of these pointers as they are pointers to constant data. You can initialise them during declaration. For example...
LPCSTR foo = "ABCDEF";
LPCWSTR bar = L"ABCDEF";
LPCTSTR baz = _T("ABCDEF");
... alternatively, you can declare a non constant string pointer (like LPSTR, LPTSTR or LPWSTR) which can be assigned to (with the appropriate function e.g., a strcpy_l variant) and use that pointer where a constant string pointer is expected. Or, you can use CAST to cast away the const-ness of the pointer but that's not a very good idea.
Typically, functions are declared with constant string parameters to assure the user that the function won't modify the contents of the pointer.
Typically you'd use one of the AfxMessageBox function overloads. Wow, that's worth a whole post (or two) by itself!There are basically two ways to use a DLL in unmanaged (or native) code. Load-Time (or static) linking and Run-tme linking.
With statically linked DLLs, you #include a suitable header file that describes the functions in the DLL and link to the corresponding lib file. So for example, you might create a MyStuff.dll with a corresponding MyStuff.h header file and a MyStuff.lib library fle.
Your program would #include MyStuff.h and then make use of the various functions defined by the MyStuff.h header file. When you built your program, the compiler would create unresolved references to the MyStuff functions which the Linker would then satisfy by linking to the function implementations in MyStuff.lib. When you executed your program, the OS would load the exe and then load the statically linked DLLs like MyStuff.dll.
With Run-time linking, you do all the work explicitly. You call LoadLibraryEx to load a DLL and call GetProcAddress to get a pointer to the function you want to call.
These two approaches are described here. http://msdn.microsoft.com/library/en-us/dllproc/base/using_dynamic_link_libraries.asp
For Managed Code such as C# or pure Managed C++ you can use the DllImportAttribute to describe a DLL's entry point (or points) in managed code terms and then just call those functions. The P/Invoke infrastructure will take care of loading the DLL, converting managed data types to unmanaged equivalents, calling the function etc.
The basics of using the DllImportAttribute from Managed C++ are described here: http://msdn.microsoft.com/library/en-us/vccore/html/vcwlksysimportattributetutorial.asp
A great Wiki for finding DllImport declarations for Win32 functions is http://www.pinvoke.net/
P/Invoke is very powerful, but can be challenging to use. A great book that describes everything you could ever want to know about DllImportAttribute and P/Invoke is Adam Nathan's .NET and COM http://www.amazon.com/gp/product/067232170X/sr=8-2/qid=1148440706/ref=pd_bbs_2/103-3935986-9004648 %5Fencoding=UTF8