Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jun 23rd, 2005, 5:36 PM   #1
Robert Collins
Newbie
 
Join Date: Jun 2005
Posts: 2
Rep Power: 0 Robert Collins is on a distinguished road
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);
When I first compiled the project I got the following error:

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, ...)
From what I can gather from reading the 'strsafe.h' file about the function it is a replacement for the 'sprintf()' function. As you can see the function takes 6 parameters while the implementation of it is only passes 4 parameters. I tried using NULLs as the last two parameters but that didn't work. I just got another compiler error message.

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?
Robert Collins is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:50 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC