Saturday, February 24, 2018

fix internet connection issue

fix internet connection issue

  1. Windows 10 PC will not connect to Internet
  2. As an ISP tech support rep, I have had a large number of calls since 12/9/16 reporting the same issue. Appears to be relate to the TCP/IP stack. Try the following, I have had a lot of success with it:

    1. open command prompt (admin)
    2. Type: netsh int ip reset then Enter
    3. Restart PC

  3. Resetting TCP/IP to Default
  4. How to reset TCP/IP by using the NetShell utility
  5. The Nuclear Option: Resetting The Crap Out Of Your Network Adapters in Vista
  6. Reset TCP/IP or Internet Protocol in Windows 10/8/7
  7. How to reset your network adapter in Windows 10
  8. How to permanently disable Windows Defender on Windows 10

Friday, February 23, 2018

set up Visual Studio 2008 for assembler

set up Visual Studio 2008 for assembler

  1. How to compile assembly files using vs2008?
  2. Right-click the project in the Solution Explorer window, Custom Build Rules, tick "Microsoft Macro Assembler". This ensures that any .asm files you add to your project get compiled with the custom build rule for .asm files.

    it works only when you create Windows 32 project in Visual Studio 2008: select console application, then empty project. after empty project is created, then remove all folders. in this case, no need to set up Entry Point in the Linker property tab.

    The basic question is more or less answered, but what if you want to do just assembly language in your Visual Studio project? Here is the answer:

    • Start with a General - Empty project.
    • Right-clicking on the project name in the solution explorer, set Custom Build Rules so that the Microsoft Macro Assembler is used.
    • Next, go to Project - Properties. Find the Linker in the dialog box and expand it (click on the +).
    • Under the Linker, select System.
    • On the top line, Subsystem, click the down arrow and choose "Console (/SUBSYSTEM:CONSOLE)."
    • In the same dialog box under Linker, select Advanced.
    • Edit the top line, Entry Point, so that it is the label you used as the starting point of your code. Note: You should not enter the underscore when filling
    • in the Entry Point. VS apparently adds an underscore.
    • Your environment is now set to do assembly langauge programming as a project.

    The procedure works also in Microsoft's free Visual C++ 2008 Express edition which is still downloadable from MS as of the date of this posting. Good luck and have fun!

  3. How to run Assembly Programs in Visual Studio
  4. How to run Assembly Programs in Visual Studio
  5. Guide to Using Assembly in Visual Studio .NET

decorator patterns

Saturday, February 10, 2018

dllmain example

tips and tricks on pre-compiled header

tips and tricks on pre-compiled header. my note is taken from the following posts.

  1. Precompiled headers
  2. Preparations

    With Visual C++ 6.0 you have to run devenv.exe with the undocumented /y3 option.
    In Visual Studio .Net you can get similar functionality by going to Tools->Options->Projects->VC++ Build and setting Build Timing to Yes.

    add some variation on this line to all copies of windows.h on my machine:
    #pragma message("Compiling windows.h - this should happen just once per project.\n")

    Setting up precompiled headers

    The only precompiled header settings that are efficient to use are the Create/Use pair of settings.( The documentation for these settings tells you what each setting does, but it fails to give you the big picture - it doesn't tell you how to setup a project to use these two together.)

    The basic idea is that one cpp file is specified as creating the precompiled header file and the other cpp files uses that precompiled header file. Because only one source file ever creates the precompiled header file it is guaranteed that it will only get built once per total rebuild.

    First you need to have one header file that every source file in your project will include. This is typically called stdafx.h or precompiled.h. If you don't have such a file, create it now. Check it to make sure it is including the appropriate set of header files - big header files that never change. Now make sure that every source file in your project is including this header file as the first non-comment thing that they do.

    Now you need one source file whose only job is to create the precompiled header file. It's best to have a source file exclusively for this purpose because every time this source file is modified, the .pch file will be regenerated. Generating the .pch file is an expensive operation that we are trying to avoid. This source file will typically be called stdafx.cpp or precompiled.cpp - to match the header file.

    Now it's time to go to project settings.

    1. First, make sure you select "All Configurations" so that your fixes will affect both debug and release builds of your project.

    2. Now, go to the C/C++ tab, precompiled headers category. Select "Use precompiled header file" and type in the name of your precompiled header file (stdafx.h or precompiled.h).

    3. If you try to build now your build will fail, giving a cryptic error about how it doesn't know how to create the .pch file. You need to tell it how.
      In the explorer view in project settings, open up your project and navigate down to the .cpp file that you chose for creating the precompiled header file (in VS.Net you will select that file from the Solution Explorer).
      Select that file, with "All Configurations" still selected, and select "Create precompiled header file", and type in the name of your precompiled header file.

    4. It kind of makes sense once you go through the steps. You give VC++ one source file to create the precompiled header file, and the other files all use it. This guarantees that it won't be rebuilt unnecessarily.
      You have to #include this file from all of your source files so that if you turn precompiled headers off, your program will compile in the same manner.

    5. The one fly in the ointment, the worrisome aspect of this feature, is that there is actually no guarantee that your program will behave identically, because VC++ doesn't enforce that your #include of the precompiled header file comes first. It enforces that you include the precompiled header file in each source file, but it will happily ignore includes, defines, and other code before that include. If you notice yourself getting some strange errors after changing your precompiled header files, that's probably why.
      Go through all of your source files and make sure that your precompiled header file is included first.

    6. That's it. If you have any problems then double check all of the steps, check the problematic source files for any preprocessor directives or code before the include of the precompiled header file, and maybe do a rebuild-all for good measure. If you want an example of a properly setup project to use as a reference, use the AppWizard to create an MFC project.

    7. You may be surprised. With Visual Studio .Net you can get a hierarchical list of header files used by setting Properties->C/C++->Advanced->Show Includes to yes.

    The defaults are dangerous

    For some projects - typically non-MFC projects, but the specifics depend on what version of VC++ you are using - the project wizard's set the precompiled header option to the seductive sounding "Automatic use of precompiled headers." Microsoft itself has admitted that this option is inefficient - yet they make it the default for many projects. Unless you are exquisitely careful this "automatic" use of precompiled headers translates to "rebuilding the precompiled headers for every source file." It is difficult to avoid this and keep it working properly. Don't use it. Either disable precompiled headers, or use them properly.

    If you use the DirectX AppWizard to create a non-MFC project, the newly created project will use the "Automatic use of precompiled headers" setting. Because of this these projects will take approximately twice as long to build as they need to. You need to manually fix them to get good build performance.

  3. Speed up C++ compilation, part 1: precompiled headers

Friday, February 9, 2018

set up MASM in visual studio

lcc compiler

PE utility

graphics API research

Friday, February 2, 2018

Debugging with command-line parameters in Visual Studio

Visual C++: include files from another project in the same solution

Visual C++: include files from another project in the same solution. I take note from the following pages and put it here for my own reference.

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:
  1. Right-click on the project, and select Properties.
  2. Select Configuration Properties->C/C++->General.
  3. Set the path under Additional Include Directories.

How to include

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

#include "filename.h"

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:

// In project settings
Additional Include Directories ..\..\libroot

// In code
#include "lib1/lib1.h" // path is relative to libroot
#include "lib2/lib2.h" // path is relative to libroot

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):
  1. Right-click on the project, and select Properties.
  2. Select Configuration Properties->Linker->Input
  3. Enter the library under Additional Dependencies. for example: MyLibX.lib
  4. Linker->General->Additional Library Directories: ..\MyLibX;
    //(for example). if adding reference is set, we still need to set up this step.
    we can combine 3) and 4) in 3) as: ..\MyLibX\MyLibX.lib

the above notes are from following links.

  1. visual c++: #include files from other projects in the same solution
  2. #include files from another project in Visual Studio Solution

SQLite