C++/VB - strsafe.lib
Asked By RB
08-Apr-10 12:43 PM
A few weeks ago Joe enlightened me as to the usage of StringCchCopy
instead of strcpy. Well I had some other things come up and had to put
all that on hold, but now I am back to that.
I downloaded the correct PlatformSDK 2003 that says it is supposed
to work with my VC pro v.6. sp5, I then extracted the whole SDK to a
temp folder using the PSDK-FULL.bat . I then searched thru the whole
bunch of cabs and found the strsafe.h and strsafe.lib files. I copied these
to my VC include and lib folders respectively. I then included the strsafe.h
in my stdafx.h file. But upon compile I get a whole bunch of errors starting
in the winbase.h and winuser.h, and a few redefinition errors in the strsafe.h
This is not looking too good since I am not sure if I want to risk installing the
whole SDK to my machine for fear my includes for current VC installation
may get foobarred.
Appreciate any input.
Visual Studio
(1)
PlatformSDK
(1)
StringCchCopy
(1)
Directories
(1)
OtherwiseI
(1)
Newcomer
(1)
Windows
(1)
Autocad
(1)
David Ching replied to RB
Installing the SDK puts it in a separate directory tree from the one that
came with Visual Studio. Therefore, the existing one is safe.
Visual Studio can be set to use the original one or the new one by changing
the order these appear in the VC++ Directories settings (specifically the
Include and Lib directories). As Visual Studio searches the directories in
order, you can have it give preference to either the original one or the new
one.
As you found, it seems to use strsafe you need to be building with the new
one, so you would put the new directories before the original ones. This
will let you at least try strsafe. If problems arise, you can always just
not use strsafe and put the directories back in the settings.
-- David
Joseph M. Newcomer replied to RB
See below....
****
I am sorry, there is no such thing as "a whole bunch of errors". There is a list of
errors, which have specific text and which have specific error numbers, and they are
reporting on specific lines of the files. WIthout knowing what those error messages say,
and where you included strsafe.h relative to the other header files, there is no way to
tell what happened.
I usually put strsafe.h at the end of my list of header files in stdafx.h.
joe
****
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
RB replied to Joseph M. Newcomer

Hey Joe, I kinda had a feeling you would ask for this but did not want to clog
up the issue with a big text paste prior to maybe a simple solution with the SDK
Anyhow here are the errors and warnings, they are the same whether I put the
I am going to try the other posters suggestion of installing the SDK to a separate
folder. I was afraid the install might foobar the registy if it spotted my VC 6.x install.
But it appears I can switch back and forth by just changing the include folders path.
Anyhow here they are, I meant to get back sooner but got bogged down at work
---------------Configuration: Try_2 - Win32 Debug--------------------
Compiling...
StdAfx.cpp
c:\program files\microsoft visual studio\vc98\include\winbase.h(3418) : warning C4229: anachronism used : modifiers on data are
ignored
c:\program files\microsoft visual studio\vc98\include\winbase.h(3419) : error C2226: syntax error : unexpected type 'LPSTR'
c:\program files\microsoft visual studio\vc98\include\winbase.h(3425) : warning C4229: anachronism used : modifiers on data are
ignored
c:\program files\microsoft visual studio\vc98\include\winbase.h(3426) : error C2226: syntax error : unexpected type 'LPWSTR'
c:\program files\microsoft visual studio\vc98\include\winbase.h(3432) : warning C4005: 'lstrcpy' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6500) : see previous definition of 'lstrcpy'
c:\program files\microsoft visual studio\vc98\include\winbase.h(3438) : warning C4229: anachronism used : modifiers on data are
ignored
c:\program files\microsoft visual studio\vc98\include\winbase.h(3439) : error C2226: syntax error : unexpected type 'LPSTR'
c:\program files\microsoft visual studio\vc98\include\winbase.h(3445) : warning C4229: anachronism used : modifiers on data are
ignored
c:\program files\microsoft visual studio\vc98\include\winbase.h(3446) : error C2226: syntax error : unexpected type 'LPWSTR'
c:\program files\microsoft visual studio\vc98\include\winbase.h(3452) : warning C4005: 'lstrcat' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6524) : see previous definition of 'lstrcat'
c:\program files\microsoft visual studio\vc98\include\winerror.h(7933) : warning C4005: 'FAILED' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(44) : see previous definition of 'FAILED'
c:\program files\microsoft visual studio\vc98\include\winuser.h(188) : warning C4229: anachronism used : modifiers on data are
ignored
c:\program files\microsoft visual studio\vc98\include\winuser.h(189) : error C2226: syntax error : unexpected type 'LPSTR'
c:\program files\microsoft visual studio\vc98\include\winuser.h(195) : warning C4229: anachronism used : modifiers on data are
ignored
c:\program files\microsoft visual studio\vc98\include\winuser.h(196) : error C2226: syntax error : unexpected type 'LPWSTR'
c:\program files\microsoft visual studio\vc98\include\winuser.h(202) : warning C4005: 'wvsprintf' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6575) : see previous definition of 'wvsprintf'
c:\program files\microsoft visual studio\vc98\include\winuser.h(205) : warning C4229: anachronism used : modifiers on data are
ignored
c:\program files\microsoft visual studio\vc98\include\winuser.h(205) : error C2226: syntax error : unexpected type 'LPSTR'
c:\program files\microsoft visual studio\vc98\include\winuser.h(206) : warning C4229: anachronism used : modifiers on data are
ignored
c:\program files\microsoft visual studio\vc98\include\winuser.h(206) : error C2226: syntax error : unexpected type 'LPWSTR'
c:\program files\microsoft visual studio\vc98\include\winuser.h(210) : warning C4005: 'wsprintf' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6566) : see previous definition of 'wsprintf'
c:\program files\microsoft visual studio\vc98\include\tchar.h(55) : warning C4005: '_ftcscat' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6563) : see previous definition of '_ftcscat'
c:\program files\microsoft visual studio\vc98\include\tchar.h(57) : warning C4005: '_ftcscpy' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6521) : see previous definition of '_ftcscpy'
c:\program files\microsoft visual studio\vc98\include\tchar.h(444) : warning C4005: '_stprintf' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6590) : see previous definition of '_stprintf'
c:\program files\microsoft visual studio\vc98\include\tchar.h(445) : warning C4005: '_sntprintf' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6593) : see previous definition of '_sntprintf'
c:\program files\microsoft visual studio\vc98\include\tchar.h(448) : warning C4005: '_vstprintf' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6584) : see previous definition of '_vstprintf'
c:\program files\microsoft visual studio\vc98\include\tchar.h(449) : warning C4005: '_vsntprintf' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6587) : see previous definition of '_vsntprintf'
c:\program files\microsoft visual studio\vc98\include\tchar.h(465) : warning C4005: '_getts' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6596) : see previous definition of '_getts'
c:\program files\microsoft visual studio\vc98\include\tchar.h(493) : warning C4005: '_tcscat' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6560) : see previous definition of '_tcscat'
c:\program files\microsoft visual studio\vc98\include\tchar.h(494) : warning C4005: '_tcscpy' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\strsafe.h(6518) : see previous definition of '_tcscpy'
Error executing cl.exe.
Creating browse info file...
Try_2.exe - 8 error(s), 22 warning(s)
--End of errors
RB replied to David Ching
(sorry meant to get back sooner but had to work late)
Thanks, I thought that might be the case but I was afraid of like
some installs will spot previous installs of VC and change or add
certain registry items and I did not want to foobar that. Years ago
I installed an Autocad ARX sdk and it tied itself to a bunch of things
in my registry that caused some problems on uninstall of an old version.
I will give your suggestion a try tonight hopefully. I have a current
image backup so it would not be a disaster in any case, but just did
not want to deal with a full image restore right now.
Joseph M. Newcomer replied to RB
I wish I could help but the only machine I had VS6 installed died, and after several weeks
my outsourced site maintenance has not been able to get the Virtual Machine which it was
reloaded onto actually working. So I cannot verify what those error lines contain, and I am
sorry. It was supposed to be working two days ago, but they never showed up to finish the
(yet another, but final, so they said) installation, and I have been tied up in
family-emergency crisis the last three days (I have been spending more time in hospitals
recently, this time as a visitor, than I have spent in the last few years as a patient)
Key here is you must not put strsafe.h ahead of ANY of the standard Windows header files,
which it looks as if you have done.
joe
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
RB replied to Joseph M. Newcomer
Thanks Joe, I will play around and see what I can do, and otherwise
I will have to give up the better Class Wizard and go with VC 2005 of
which I also own now.
I cam empathize with you on your hospital time. I have been there and
done that with both of my parents and also my father in law. It is a
rough time with that sort of stuff, but it also sobers us to realities of life
and helps sometimes to get our parameters in order as our journey
progresses to the end portal that is called by and given different definitions
by different faiths or non faiths. But it is one we all have a final destiny
with.
I pray for strength for you and your family at this time, and I ask God
give you what ever you need at this time in return for the guidance that
you have given me so many times before on technical subjects.
RB
Joseph M. Newcomer replied to RB

Thanks for the sympathy. It is not an easy time when you are told a relative has a
terminal condition.
From my own viewpoint, being told you are likely to be dead shortly is very sobering. This
is why I have no qualms about telling people very bluntly that they are wrong. I am 20
years since one surgery that was mandatory ("or you will be dead in a year") and 15 years
one that was accidental (I did not know when I went into the OR if I'd be coming out,
having lost most of my blood supply). So I do not have to maintain any pretenses. WYSIWYG
with me. I have already outlived two projections, both due to living in a city with some of
the world's best hospitals. I seem to be fixed right now, but I realize that I could not
be here tomorrow. I have three linear feet of scar tissue on my body from various
surgeries (one 8" scar has to be counted twice, since the second surgery reused it) and
do not feel I need to be overly polite when things are going wrong. I have a sense of
proportion about what matters.
I heard Jim Lovell (Apollo 13 commander) explain that after his last flight, he does not
have any problem coping with any problem; I do not recall his exact words, but they were
along the lines of "I know what serious problems are, and I have not had one since I
landed". I feel the same way. So while the care is time-consuming, I know how to get
through these crises. This is the fifth "eldercare" situation I have had to handle, and I
pretty much know who I have to talk to, what questions to ask, and what to do with the
answers. Being trained as a problem-solver helps a lot.
joe
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
RB replied to Joseph M. Newcomer

I did get my strsafe function to compile with no errors by installing the Platform SDK.
I did have to place the include at the end of the Stdafx.h file like you said though and
I also had to move the Platform SDK include path up ahead of my other includes
on my path options as David has told me. Now if I could just find some easily accessible
help files on the strsafe functions. The only files in the Platform SDK install that elude to
anything to do with help are in the installed folder of C:\Program Files\Microsoft SDK\Help
but they are all .hxi .hxs .hxq .hxr and .hxt extension files that do not open up with
anything I have ?
Enjoyed reading your reply (as always) . Even though I am off topic for this group,
I would quickly like to comment on the below.
Wow, that really transcends all description. If memory serves me correctly Jim is the one
that did hand calculus with pen and paper on the projected reentry path due to technical
failures on the return trip from the Moon. He really was quite a talented individual.
Boy that is the truth. My dad died first and 10yrs later when my Mom was ill she was so
out of congnitiveness due to the cancer and medications that I literally had to be her brain
as far as conversing with the various doctors during her care. I had to learn a lot about the
logistics of hospital protocol etc and I can definitely relate to what you are describing.
Take care Joe and hope the best for your family member.
David Ching replied to RB
The functions listed in
http://msdn.microsoft.com/en-us/library/ff468910(v=VS.85).aspx starting with
-- David
RB replied to David Ching
Wow thanks this is just what I need. Only thing is I am wondering when this page
might not be available and if there is a downloadable zip etc. that I could retrieve
and install on my local machine ?
Help: Is Visual Studio 2008 good enough (for VC++)? C++ / VB As I said earlier, VS2010 is very expensive I need new VC++. So I was thinking to buy older one, VC++2008 with Visual Studio 2008. Is this good enough to "survive" next 5 years? Does VC2010 have something essencial basic applications. And also MFC is pretty much the same I guess. I found one Visual Studio 2008 Standard version for £100. Thats a good deal and I think its best for Can somebody please confirm that this is good. VC MFC Discussions Windows Server 2003 (1) Visual Studio 2005 (1) Visual Studio 2010 (1) Visual Studio 2008 (1) Joseph M. Newcomer (1) Statistics
Visual C++ 6.0 C++ / VB This is a two-part question. . . both related to MS Visual Studio 6.0. 1) I am just starting to develop a new version of a C and is user-friendly enough. I am on Win7 now, but developing on XP. Is Visual C++ 6.0 good enough for this? In other words: is there any glaring omission the latest and greatest? 2) Are there any tips you can offer while coding in Visual C++ 6.0 that would save me tons of time should I decide to convert to the newest version of C++ Visual Studio later on? Thanks a lot for your helpful advice. VC MFC Discussions Windows XP (1 Visual Studio (1) Windows 7 (1) Linux (1) Distributed (1) Recursive (1) Money (1) Class (1
test AnswerCall functionality without running a loop which checks the calls. - Gergely Win32 TAPI Discussions Visual Studio .NET (1) QueueUserWorkItem (1) Exception (1) Class (1) Microsoft Visual Studio (1) Microsoft Corporation (1) Andreas Marschall (1) Microsoft (1) Gergely, AFAIK call completion is only default.aspx / TAPI / PSDKSamples.html - - Best Regards Andreas Marschall Microsoft MVP for TAPI / Windows SDK / Visual C++ 2003-2008 TAPI / TSP Developer and Tester My TAPI and TSPI FAQ: http: / / www to compile http: / / www.tapi.info / downloads / samples / psdk / tapi3 / cpp / samplemsp.zip with Microsoft Visual Studio .NET 2003 nmake, but I get the following errors: Microsoft (R) Program Maintenance Utility Version 3D_cdecl -DCRTAPI2 = 3D_cdecl -nologo -D_X86_ = 3D1 - DWIN32 -D_WIN32 -W3 -Z7 -I"c: \ Program Files \ Microsoft Visual Studio .NET 2003 \ Vc7 \ include" -I"c: \ Program Files \ Microsoft Visual Studio .NET 2003 \ Vc7
htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] C++ Discussions Visual Studio (1) Python (1) Oracle (1) Linux (1) Ruby (1) Perl (1) Relative (1) Restrict (1 SFINAE and static assertions are two different mechanisms that can be used to constrain templates. Visual C++, Eclipse and XCode, arguably the 3 major C++ IDEs, while quite slower than a production code in a good Java IDE (IntelliJ): C++ IDEs, even the most advanced one (Visual Studio C++), pale in comparison. The power of Java refactoring tools gives the programmer a huge up, it is much more convenient than any graphical IDE I could think of. In Visual Studio, I often have to search the GUI to find the function I need ["where is to do. So why do you use it? C++ leaves you a choice. I find Visual Studio not very usable at all. So long, Thomas - - [ See http: / / www.gotw.ca / resources
Should a hobbyist upgrade from Visual Studio C++ NET 2003? C++ / VB Will Visual C++ 2010 Express be enough to help compile my little macro recorder better than my current Visual Studio NET 2003 Standard? I use a systemwide hook written in Visual C++, a macro recorder, that must be regularly edited / modified. I took the (MFC?) stuff stripped away everything that seemed unnecessary. It has worked great for many years. I use Visual Studio C++ to change the main code and then rebuild / recompile it. For debugging, I use