![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Posts: 2
Rep Power: 0
![]() |
Using StringCchPrintfEx() instead of sprintf()
Hi everyone.
This one may be a stickler. I downloaded some sample source code from MSDN from the below link: http://msdn.microsoft.com/library/en...asp?frame=true The project 'BandObjs' is a simple example that demonstrates the implementation of the three types of band objects. These are Desk Bands, Explorer Bars and Communication Bands. In the source code 'BandObjs.cpp' I encountered the following line: hr = StringCchPrintfEx(szSubKey,
MAX_PATH,
ClsidEntries[i].szSubKey,
szCLSID);error C2065: 'StringCchPrintfEx' : undeclared identifier. So, since it wasn't included in the download I was able to find it in my Microsoft SDK\Include\strsafe.h file. So, I included this file in the project and recompiled it. After that I get the following error: error C2660: 'StringCchPrintfExA' : function does not take 4 parameters The definition of the function is given below: STRSAFEAPI StringCchPrintfExA(char* pszDest,
size_t cchDest,
char** ppszDestEnd,
size_t* pcchRemaining,
unsigned long dwFlags,
const char* pszFormat, ...)The problem that I am up against is that I don't know how to make it work. Does anyone know what I can do to the code so that I can get the desired results, either by changing the function definition or changing the function implementation? |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 894
Rep Power: 4
![]() |
Google is your friend here - the first hit (of two) is the documentation of the function. Or you can click here
I think this is a typo in the sample code - it looks like it should be using the StringCchPrintf function, which matches the paremeters. If you really want to use the StringCchPrintfEx function, I think what you want is to pass NULL as the third and fourth arguments to the function, and 0 as the fifth argument (the flags) so your call would be hr = StringCchPrintfEx(szSubKey,
MAX_PATH,
NULL,
NULL,
0,
ClsidEntries[i].szSubKey,
szCLSID); |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jun 2005
Posts: 2
Rep Power: 0
![]() |
Dark,
Thanks for the link. That helps alot about the function. Also, many more thanks for posting your version of using the function. I didn't understand it at first because you used 7 parameters instead of 6 but after reading more about the function at that link I think I got the drift. BTW: your version works perfectly. Again, thanks for your response. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|