Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

strsafe.lib

264 views
Skip to first unread message

RB

unread,
Apr 8, 2010, 12:43:32 PM4/8/10
to
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 isn't looking too good since I'm 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.


David Ching

unread,
Apr 8, 2010, 3:54:15 PM4/8/10
to
"RB" <NoMail@NoSpam> wrote in message
news:ODiAoqz1...@TK2MSFTNGP06.phx.gbl...

> This isn't looking too good since I'm 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.

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

unread,
Apr 8, 2010, 8:53:38 PM4/8/10
to
See below....

****
I'm 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
****
>Appreciate any input.
>
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

RB

unread,
Apr 9, 2010, 2:14:11 PM4/9/10
to
> I'm 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

Hey Joe, I kinda had a feeling you would ask for this but didn't 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
#include <strsafe.h> at the beginning or end of StdAfx.h.
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

unread,
Apr 9, 2010, 2:21:41 PM4/9/10
to
(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

unread,
Apr 9, 2010, 11:37:51 PM4/9/10
to
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 can't verify what those error lines contain, and I'm
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've been spending more time in hospitals
recently, this time as a visitor, than I've 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

RB

unread,
Apr 10, 2010, 8:46:17 AM4/10/10
to
>I wish I could help but the only machine I had VS6 installed died,.........
>.........................So I can't verify what those error lines contain, and I'm
>........... I have been tied up in family-emergency crisis the last three days

>(I've been spending more time in hospitals recently, this time as a visitor,
>than I've spent in the last few years as a patient)
>==========================================
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

unread,
Apr 11, 2010, 4:24:22 PM4/11/10
to
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'm 20
years since one surgery that was mandatory ("or you'll be dead in a year") and 15 years
one that was accidental (I didn't know when I went into the OR if I'd be coming out,
having lost most of my blood supply). So I don't have to maintain any pretenses. WYSIWYG
with me. I've 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
don't 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 doesn't
have any problem coping with any problem; I don't recall his exact words, but they were
along the lines of "I know what serious problems are, and I haven't 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've 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

RB

unread,
Apr 11, 2010, 6:19:20 PM4/11/10
to
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 don't 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.

>I heard Jim Lovell (Apollo 13 commander) explain that after his last flight, he doesn't
>have any problem coping with any problem; I don't recall his exact words, but they were
>along the lines of "I know what serious problems are, and I haven't had one since I
>landed".

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.

> This is the fifth "eldercare" situation I've 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

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

unread,
Apr 11, 2010, 9:49:03 PM4/11/10
to
"RB" <NoMail@NoSpam> wrote in message
news:uUP6JUc2...@TK2MSFTNGP05.phx.gbl...

> Now if I could just find some easily accessible
> help files on the strsafe functions.

The functions listed in
http://msdn.microsoft.com/en-us/library/ff468910(v=VS.85).aspx starting with
"String" are what you want.

-- David

RB

unread,
Apr 12, 2010, 7:37:22 AM4/12/10
to
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 ?


0 new messages