Why are windows definitions missing on msvc++ - winapi

I have not been coding in MSVC lately. I have been assigned an old code that has lots of errors but most of the missing definitions are of Windows API.
For example, LPHANDLER_FUNCTION_EX is not defined and is causing C2061 compile error. But I already included Winsvc.h or Windows.h. I know that this is just a definition, I checked my C:\Program Files\Microsoft SDK\ for the definition can be found on the Winsvc.h. So I added the SDK on the directory list (Tools > Options > Directory Tab).
I also downloaded the Windows SDK February 2003 update which is the last version that works with msvc6. (ref)
Just for completeness, My PC is Windows XP SP3. Microsoft Visual C++ Enterprise Edition with SP6 installed. I also installed the Windows SDK February 2003 update.
Any ideas?

I was able to solve this by fixing the order of the include directory via Tools > Options > Directory Tab.
Before the VC98 folder was on top of the SDK.
1st C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
2nd C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
3rd C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
4th C:\Program Files\Microsoft SDK\include
Just place the SDK directory to the top of the list and it works.
The suggestion to use /E option by jamesdlin was helpful. Also I set the /E option in the Project Settings > Library Tab > Project Option textbox. The log would be placed in the .plg file inside the project folder.
This would also apply to missing lib file. Set the directory to the SDK directory for library.

Related

Visual Studio 2022: Cannot open include file: 'ctype.h'

I've got the infamous error message in C++ build: "Cannot open include file: 'ctype.h'". I know a similar question was already asked multiple times, but my case seems different because I am using the latest Visual Studio 2022 and seems to behave differently.
I have a bunch of existing C++ projects, they use plain 32-bit Windows API with DirectX 6, and I used VC++ build tools 2015 and Windows SDK 8.1 to compile it without any issues in previous versions of Visual Studio. Everything was fine in Visual Studio 2019, no special setup was needed, until I uninstalled it and installed Visual Studio 2022.
Now I can open my solutions, it nicely shows they are using C++ build tools 2015, which I installed together with VS2022, and the solutions also shows correctly that they use Windows 8.1 SDK. But Windows 8.1 SDK is not present in VS2022 installation, I installed it separately. I also tried to "repair" VS2022 installation, but that only deleted all my UI preferences, but not fixed anything in build. Also, I tried to reinstall Windows 8.1 SDK, but it said it is already OK.
When looking to Visual Studio, I can't see any place where I can set default include and lib directories, I can only list what is being used right now. VS2022 shows this list:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
C:\Program Files\Windows Kits\10\Include\10.0.10240.0\ucrt
C:\Program Files (x86)\Windows Kits\8.1\Include\um
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
C:\Program Files (x86)\Windows Kits\8.1\Include\winrt
The actual error message I receive is this:
c:\program files (x86)\windows kits\8.1\include\um\winnt.h(31): fatal error C1083: Cannot open include file: 'ctype.h': No such file or directory
So it says that winnt.h from windows kits 8.1 cannot find ctype.h. And yes, there is no ctype.h in that folder or anywhere around, I can see it only in C:\Program Files\Microsoft Visual Studio\2022\Professional\SDK\ScopeCppSDK\vc15\SDK\include\ucrt
which I think is the folder with VC++ 2015 build tools. So this seems correct, but I am wondering why this folder is not a part of default include directories when VC++ 2015 build tools are set in project settings. Because it seems that VS2022 is correctly picking my Windows 8.1 SDK, but not picking correctly the older C++ compiler.
When I try to add the folder where ctype.h resides to include folders, I receive another type of errors saying that other files are incompatible with these include files. Of course, this system of directories needs to be in sync. So please what is the correct way of using this?
Also, I tried to switch the VC++ build tools to 2022 version. Unfortunately, that also does not fix the issue. And Windows 10 SDK is not installed, the software wants to stay compatible with older Windows, so I don't need it.
I found a bug report which is related: https://developercommunity.visualstudio.com/t/windows-81-sdk-1/151682
Although Microsoft staff declined to accept it as a bug, it is happening for me as well. When I install only Windows 8.1 SDK, no project can be compiled with it. I even tried to create a new Windows API project in VS2022, the project was created, but failed to compile with the same error.
So I tried to install Windows 10 SDK (from VS2022 installed, but that is probably not important) and this added some missing files which now help to compile Windows 8.1 SDK projects. Problem seems to be solved, my old C++ code can now be compiled with Windows 8.1 SDK and both C++ build tools 2015 and 2022.

Why does 'iprtrmib.h' in Window Kits 8.0 reference 'mprapidef.h' in window 'kits 8.1'?

I am using Visual Studio 2012 (Update 5) with MS Window Kits 8.0 and .NET Framework 4.5.51209. Recently, I also installed MS Window Kits 8.1.
Now, I have a file: '\windows kits\8.0\include\shared\iprtrmib.h' that failes to include 'mprapidef.h'.
That include file only exists at: '\Windows Kits\8.1\Include\shared\mprapidef.h', which is not in my include path.
My Visual Studio 'Include Directories' is set to: "$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);".
These are my Visual Studio macros:
VCInstallDir: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\
WindowsSDK_IncludePath: C:\Program Files (x86)\Windows Kits\8.0\Include\um;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\winrt
When searching, I found a slightly similar question: missing header file on a new installation of visual studio 2012
I tried repairing my Visual Studio installation. I do not want to change the 'Include Directories' for each of my projects. What else should I try?
I installed vs2015 and vs2012, then the same problem occurs,however, I find a solution.
open visual studio project settings,click VC++ Directories, find Include Directories,add the following line to it.
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
One may add the corresponding 8.1 paths to the environment variable.
Maybe it's necessary to do the same thing with the lib environment variable (WindowsSDK_LibraryPath_x86).

How to install SignTool.exe for Windows 10

How to install SignTool.exe in Visual Studio 2015 for Windown 10?
I tried to build my project but the program threw an error :
Error An error occurred while signing: SignTool.exe not found.
You need to install the Windows 10 SDK.
Visual Studio 2015 Update 1 contains it already, but it is not installed by default. You should go to Control Panel -> Programs and Features, find Microsoft Visual Studio 2015 and select "Change".
Visual Studio 2015 setup will start. Select "Modify".
In Visual Studio components list find "Universal Windows App Development Tools", open the list of sub-items and select "Windows 10 SDK (10.0.10240)".
Windows 10 SDK in VS 2015 Update 1 Setup
Of cause you can install Windows 10 SDK directly from Microsoft: https://go.microsoft.com/fwlink/?LinkID=698771
As josant already wrote - when the installation finishes you will find the SignTool.exe in the folders:
x86 -> c:\Program Files (x86)\Windows Kits\10\bin\x86
x64 -> c:\Program Files (x86)\Windows Kits\10\bin\x64\
If you only want SignTool and really want to minimize the install, here is a way that I just reverse-engineered my way to:
Download the .iso file from https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk (current download link is http://go.microsoft.com/fwlink/p/?LinkID=2022797) The .exe download will not work, since it's an online installer that pulls down its dependencies at runtime.
Unpack the .iso with a tool such as 7-zip.
Install the Installers/Windows SDK Signing Tools-x86_en-us.msi file - it's only 388 KiB large. For reference, it pulls in its files from the following .cab files, so these are also needed for a standalone install:
4c3ef4b2b1dc72149f979f4243d2accf.cab (339 KiB)
685f3d4691f444bc382762d603a99afc.cab (1002 KiB)
e5c4b31ff9997ac5603f4f28cd7df602.cab (389 KiB)
e98fa5eb5fee6ce17a7a69d585870b7c.cab (1.2 MiB)
There we go - you will now have the signtool.exe file and companions in C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64 (replace x64 with x86, arm or arm64 if you need it for another CPU architecture.)
It is also possible to commit signtool.exe and the other files from this folder into your version control repository if want to use it in e.g. CI scenarios. I have tried it and it seems to work fine.
(All files are probably not necessary since there are also some other .exe tools in this folder that might be responsible for these dependencies, but I am not sure which ones could be removed to make the set of files even smaller. Someone else is free to investigate further in this area. :) I tried to just copy signtool.* and that didn't work, so at least some of the other files are needed.)
Here's where you'll find it:
C:\Program Files (x86)\Windows Kits\10\App Certification Kit
Screenshot:
Best solution end of 2020:
Just download Windows 10 SDK from Microsoft here:
https://go.microsoft.com/fwlink/?LinkID=698771
In setup, choose only Windows App Certification App (it's only 184 MB)
You can find signtool.exe here:
%PROGRAMFILES(X86)%\Windows Kits\10\bin\x64
Cheers!
As per the comments in the question... On Windows 10 Signtool.exe and other SDK tools have been moved into "%programfiles(x86)%\Windows Kits\".
Typical path to signtool on Windows 10.
32 bit = "c:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe"
64 bit = "c:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe"
Tools for SDK 8.0 and 8.1 also reside in the "Windows Kits" folder.
Another answer from 2021.
You might not need Windows SDK at all. If you have VS-2019 installed, you might already have signtool in C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe
NOTE: The good thing about this particular signtool version (compared to the Windows SDK one), is that it's self-contained, and does not need all the dll's next to it (mssign32.dll, wintrust.dll etc, which usually lie around in Windows SDK folders).
You can even add this file to your source code repo (just one file), since this tool hasn't changed since 2016.
P.S. I had this signtool even without "ClickOnce publishing" component installed in my Visual Studio Community Edition.
Location:
C:\Program Files (x86)\Windows Kits\10\App Certification Kit\signtool.exe
In 2019, this is a quite recent link from Microsoft about how to obtain this tool:
The SignTool tool is a command-line tool that digitally signs files,
verifies signatures in files, or time stamps files. For information
about why signing files is important, see Introduction to Code
Signing. The tool is installed in the \Bin folder of the Microsoft
Windows Software Development Kit (SDK) installation path.
SignTool is available as part of the Windows SDK, which you can
download from https://go.microsoft.com/fwlink/p/?linkid=84091.
I only needed signtool, so I chose the minimal I came up with and signtool.exe is now in C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\signtool.exe
Microsoft article link:
https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool
to install just the signingtools from the winsdksetup.exe (available at the same url as the windows sdk iso mentioned above) this is an option to, straight from the Dockerfile i'm working in:
RUN powershell Start-Process winsdksetup.exe -ArgumentList '/features OptionId.SigningTools', '/q', '/ceip off', '/norestart', -NoNewWindow -Wait
so if you're in windows then that'd be:
winsdksetup.exe /features OptionId.SigningTools
winsdksetup /h gives you the options, so i won't summarise them here.
I include the dockerfile snippet, as that is what i started my day looking for the solution for.
You don't have to install the Signtool. It might already be there.
Go to C:\Program Files (x86)\ and search for signtool.exe. In my system I found it under C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool
No matter which version of Windows you are using, the above signtool will solve your purpose.
If you're using VS Express 2015, just go to your control panel --> programs and features --> select vs 2015 --> click change, then in the VS Express installer select 'Modify' --> select Publishing tools, and finish. Once setup completes the changes you will be able to create your installer.
You should go to Control Panel -> Programs and Features, find Microsoft Visual Studio 2015 and select "Change".
Visual Studio 2015 setup will start. Select "Modify".
In Visual Studio components list, open the list of sub-items and select "ClickOnce Publication Tools" and "Windows 10 SDK" too.
I did a modify with the Visual Studio from Control Panel, Programs and Features. The SDK was not at first apparent so I installed the Common Tools which lo and behold did include the SDK Update 3.
It's available many, many places, depending upon what is installed:
On my box, every one except the v6.0A SDK version supports the /fd option.
SignTool is available as part of the Windows SDK (which comes with Visual Studio Community 2015). Make sure to select the "ClickOnce Publishing Tools" from the feature list during the installation of Visual Studio 2015 to get the SignTool.
Once Visual Studio is installed you can run the signtool command from the Visual Studio Command Prompt.
By default (on Windows 10) the SignTool will be installed in:
C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe
For me in 2021 the signtool.exe was here: "C:\Program Files (x86)\Windows Kits\10\bin\x64" or in: x86
and not under: C:\Program Files (x86)\Windows Kits\10\App Certification Kit
even if I have this folder and may files in it.
I ran into an issue using this tool in a restrictive Azure DevOps Pipelines environment, where I couldn't even expand PATH or call any tools from an absolute path outside of the ADO build directories, meaning in this case anything from C:\Program Files (x86)\
My solution was to package it as a Secure File in ADO Pipelines' Library -> Secure Files section, allow my pipeline to access the file via its security settings, then download it as a build task and run it via a powershell task.
In the example below, I just query the help with the /? command. Just replace that with whatever command you want to use.
- task: DownloadSecureFile#1
displayName: "Signtool Download"
name: MSSignTool
inputs:
secureFile: 'signtool.exe'
- task : PowerShell#2
displayName: "Run Signtool"
inputs:
targetType: "inline"
script: $(MSSignTool.secureFilePath) /?
Warning 1: I'm not sure what dependencies are required for signtool.exe to work standalone, or if it even has any. The Windows 10 SDK and ADK was already installed in this build environment. If querying the help causes the tool to fail or crash, make sure one or both of those are installed. Hopefully you will have access to something like choco to install any missing dependencies.
Warning 2: Be careful if copying those code segments. ADO is pretty strict with dynamic whitespace, so if your spacing is off it will brick your whole pipelines file until you adjust the spacing to its correct position.

Visual Studio Code install location

I installed Visual Studio Code a few days ago, and now I can't find the executable on my machine. Where is it?
I have checked Programs and Features. I have also checked my PATH. For some reason it isn't in either.
Update 10.11.2018
If you do a complete re-install, including uninstalling prior versions of code installed on your machine the new version will be installed at
C:\Users\{UserName}\AppData\Local\Programs\Microsoft VS Code
Update 06.07.2018
Since Version 1.25 VS Code supports portable mode.
Instructions on how to use this are documented here.
You will need the ZIP file download version - not the installer.
After unzipping the contents of the archive, create a data folder inside the folder, where code.exe is located. All settings will now be saved there and can be brought along with you.
|- VSCode-win32-x64-1.25.0-insider
| |- Code.exe (or code executable)
| |- data
| |- ...
On macOS, the folder must be named code-portable-data and has to be a sibling of the app itself. Not inside the app.
|- Visual Studio Code.app
|- code-portable-data
The reasoning behind this can be read here: What is VSCode User Setup for Windows?
Update
If you are using the x64 version, the path is:
C:\Program Files\Microsoft VS Code\
C:\Program Files\Microsoft VS Code\Code.exe
Original answer
At this point and time (Version 1.19.2) Vs code no longer resides in your AppData folder, but under
C:\Program Files (x86)\Microsoft VS Code\
C:\Program Files (x86)\Microsoft VS Code\Code.exe
There are two types of installer available for VSCode.
Go to link to find type of installer you want.
If you are using/going for User Installer, the version will be installed at:
C:\Users\{UserName}\AppData\Local\Programs\Microsoft VS Code
If you are using/going for 64bit System installer, the version will be installed at:
C:\Program Files\Microsoft VS Code\
If you are using/going for 32bit System installer, the version will be installed at:
C:\Program Files (x86)\Microsoft VS Code\
I used the new VSCode User Setup installer on Windows 10, and found the executable here:
C:\Users\my-username\AppData\Local\Programs\Microsoft VS Code\
Okay. I found it in the docs.
C:\Users\my.user\AppData\Local\Code\app-0.1.0
The way I find most intuitive and easy to remember is:
Search for Visual Studio Code in the Windows 10 search bar -> right-click -> Open File Location
For me this goes directly to:
C:\Users\{YOUR_NAME}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Visual Studio Code
Right-click on the shortcut -> Properties -> Start in:
"C:\Users\{YOUR_NAME}\AppData\Local\Programs\Microsoft VS Code"
If you prefer username-agnostic path strings:
folder: %HOMEPATH%\AppData\Local\Programs\Microsoft VS Code\
executable: %HOMEPATH%\AppData\Local\Programs\Microsoft VS Code\bin\code
If you also want to use those path strings inside C#/C++ code:
folder: "\"%HOMEPATH%\\AppData\\Local\\Programs\\Microsoft VS Code\\\""
executable: "\"%HOMEPATH%\\AppData\\Local\\Programs\\Microsoft VS Code\\bin\\code\""
If for some reason none of the other answers work, try this:
Go into your vscode settings
Find any setting that has 'Edit in settings.json' (for example - Color Customizations)
Press ctrl+shift+s
Go one folder up
Copy + paste the file location (on the top for windows) into into another file explorer
Profit
The difference is:
System Installer will install VSC in C:\Program Files\Microsoft VS Code\
User Installer will install VSC in %HOMEPATH%\AppData\Local\Programs\Microsoft VS Code\
Search for the files with respect the version installed.
Why default your program would be installed here..
C:\Program Files\Microsoft VS Code\
If you have chosen different directory while installing it you can get it by:
1. Go to the icon location
2. Right click open properties
3. Check target
I found it at
C:\Users\%username%\source\repos\Notes\%VSCode-folder%\bin\Debug\
Where %username% is the user and %VSCode-folder% is the VSCode project

signtool.exe not found in vs2008

I'm trying to publish a program in vs2008 but I get the following error,
can not publish because a project failed to build.
An error occurred while signing: signtool.exe not found.
I've been searching Google for some time now but I can't find the answer.
I can't find signtool.exe; can anyone tell me where I can get it?
signtool.exe is included with the Windows SDK, and a copy of the Windows SDK is included with VS2008.
It should be installed as %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\bin\signtool.exe, but it might depend on installation options.
Another route is to install the Windows SDK directly (latest version includes Win7/2008R2 support).
VS 2008 - This tool is located at,
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
Probably you could find in any one of this location.
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin

Resources