From: RB on
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.


From: David Ching on
"RB" <NoMail(a)NoSpam> wrote in message
news:ODiAoqz1KHA.5972(a)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

From: Joseph M. Newcomer on
See below....
On Thu, 8 Apr 2010 12:43:32 -0400, "RB" <NoMail(a)NoSpam> wrote:

>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.
****
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: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: RB on
> 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


From: RB on
(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.