good morning, I would ask gently a question about a c++ code. I want to create and write on a .bat file with c++. This file must be located in the startup folder of windows but for that I had to know the name of the current user in order to write FILE.open("C:\\Users\\nameUsers\\...") but I don't know nameUser of all machines. I would ask if exist a function to obtain that or if other ways exist to do what I need. Infact I'm interesting to know how programmers create installer programs which create files in some folders of my machine without knowing the name of the user. Secondly I would ask if some examples for that exist.
Thank you very much
Best Regards
how programmers create installer programs which create files in some folders of my machine without knowing the name of the user.
They probably used Windows Installer, a service included with Windows.
https://msdn.microsoft.com/en-us/library/windows/desktop/cc185688(v=vs.85).aspx
Windows Installer can install applications as well as patching already installed applications.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa367449(v=vs.85).aspx
There are companies that create an installer creation application that makes entering all the needed information easier for the programmer, InstallShield being one.
http://www.flexerasoftware.com/producer/products/software-installation/installshield-software-installer/
Problem was that you were not willing or smart enough to google what include file you needed for sprintf_s.
Thanks for reply, I googled it but https://msdn.microsoft.com/en-us/library/ce3zzk1k.aspx refers
that necessary headers are:
sprintf_s, _sprintf_s_l
C: <stdio.h>
C++: <cstdio> or <stdio.h>
(Scroll down to requirements section) that I have already added and still doesn't work.
Passing FOLDERID_Startup as the KNOWNFOLDERID will obtain the path to the current user's startup folder, FOLDERID_CommonStartup will give you the path of the shared startup folder. You should not try to concoct the path by querying for the username, etc.
The link that Thomas1965 provided is to the deprecated SHGetFolderPath() call, which should only be used if you have to support pre-Vista systems.