How to find the systemroot (in C#, C++ and Java)

Naturally, a lot of my search engine traffic comes here from searching for terms like “system root in &ltinsert language here>” or “%systemroot%”. So, to live up to my domain, and you Googler’s expectations, I’ve decided to write a post about how to get the path to the system root in a few languages. If you know more, drop a comment and I’ll add it here.

Read the rest of this entry »

Saving to a Custom Binary File Format with Versioning

While working on Fondusi’s I came up with a great way to store the map data (or any binary data, really) in such a way that previous files could be loaded using new versions of the software. It has some great capabilities and, after answering a question about it on gamedev.StackExchange, I thought it might be helpful to write a post about it here.

Read the rest of this entry »

C# Image.Save Always Outputs PNG Format

I recently had to work on a project where I needed to open an image, rotate it by 90 degrees and save it again in C#. I was having some issues where it would always save the image in the PNG format regardless of what format it was loaded from. Here’s the code that I had:
Read the rest of this entry »

Visual Studio C++ Edit Include Paths/Linker Settings

I’m posting this info on how to set up extra include paths and edit linked files in Visual Studio for my own reference.

This was originally acquired from here on October 10, 2010.

Settings for compiler

In the project where you want to #include the header file from another project, you will need to add the path of the header file into the Additional Include Directories section in the project configuration.

To access the project configuration:

  • Right-click on the project, and select Properties.
  • Select Configuration Properties->C/C++->General.
  • Set the path under Additional Include Directories.

How to include

To include the header file, simply write the following in your code:

Note that you don’t need to specify the path here, because you include the directory in the Additional Include Directories already, so Visual Studio will know where to look for it.

If you don’t want to add every header file location in the project settings, you could just include a directory up to a point, and then #include relative to that point:

Setting for linker

If using static libraries (i.e. .lib file), you will also need to add the library to the linker input, so that at linkage time the symbols can be linked against (otherwise you’ll get an unresolved symbol):

  • Right-click on the project, and select Properties.
  • Select Configuration Properties->Linker->Input
  • Enter the library under Additional Dependencies.

Latest Posts

Post Calendar

April 2023