Tag Archives: Microsoft

Compiling a C Program from Visual C++ 2015 Command Prompt

For quick compiling of C/C++ programs on a Windows PC,  the Visual C++ 2015 Command Prompt is your go to program. Many programs have no need for development in an IDE.

Before you can compile a c/c++ program you will need to install the Microsoft Visual C++ Build Tools 2015.

Once installed you will have a new list of shortcuts in your Start Menu.

Visual C++ Build Tools Start Menu Shortcuts
Visual C++ Build Tools Start Menu Shortcuts

If you right click on any one of the Visual C++ 2015 Programs and choose Open File Location you will also see the extensive list of tools.

Visual C++ Build Tools Explorer Shortcuts
Visual C++ Build Tools Explorer Shortcuts

Depending on what system architecture you are running, open one of the programs. If in doubt select:
Visual C++ 2015 x86 Native Build Tools  Command Prompt
or
Visual C++ 2015 x64  x86 cross Build Tools  Command Prompt

The following window will appear:

Visual C++ 2015 Build Tools Command Prompt
Visual C++ 2015 Build Tools Command Prompt

To verify that the prompt is functioning property, type cl and the prompt will output the exact same information again.
Note: You can use the Visual C++ 2015 Build Tools Command Prompt the same way you would use the standard command prompt for directory navigation.

  1. To test a simple C program, first create a test directory to hold your test program. md c:\test to create a directory, and then enter cd c:\test to change to that directory. This is where your source files and executable will be stored.
  2. Type notepad test.c  When the  Notepad alert dialog  pops up, choose Yes to create the new test.c file in your current working directory.
  3. In Notepad, enter the following code and save as test.c:
#include <stdio.h>
int main()
{
printf("Hello World!\n");
getchar(); //used to prevent executable from closing when double clicked
return ;
}
  1. Now from the Visual C++ Build Tools Command Prompt type: cl test.c. If the program compiled successfully you will see: /out:test.exe and test.obj. In your test folder you will now have the test.c source file along with test.obj and test.exe
  2. To run your newly compiled program simply type test and your program will run in the command prompt. You can also double click the test.exe executable.

To compile a program with more than one source file simply type:

cl test.c test2.c test3.c

The compiler will output a single file called file test.c
To change the name of the output program, add an /out linker option:

cl test.c test2.c test3.c /link /out:mynewprogram.exe

test.c source file

Microsoft SQL Server Quick Reference

String Functions
Exact Numerics
bigint
bit
decimal
numeric
money
smallint
tinyint

Approximate Numerics
float
real

Date and Time
datetime
smalldatetime
timestamp

Strings
char
text
varchar

Unicode Strings
nchar
ntext
nvarchar

Binary Strings
binary
image
varbinary

Misc
cursor
sql_variant
table
xml

Type Conversions
CAST(expression AS datatype)
CONVERT(datatype, expression)

Ranking Functions
DENSE_RANK
NTITLE
RANK
ROW_NUMBER

Grouping Aggregate Functions
AVG
BINARY_CHECKSUM
CHECKSUM
CHECKSUM_AVG
COUNT
COUNT_BIG
GROUPING
MAX
MIN
SUM
STDEV
STDEP
VAR
VARP

Table Functions
ALTER
CREATE
DROP
TRUNCATE

Date Functions
DATEADD(datepart, number, date)
DATEDIFF(datepart, start, end)
DATENAME(datepart, date)
DATEPART(datepart, date)
DAY(date)
GETDATE()
GETUTCDATE()
MONTH(date)
YEAR(date)

Dateparts
Year                                yy, yyyy
Quarter                        qq, q
Month                           mm, m
Day of Year                 dy, y
Day                                  dd, d
Week                             wk, ww
Hour                               hh
Minute                          mi, n
Second                          ss, s
Millisecond                ms

Mathematical Funcations
ABS
ACOS
ASIN
ATAN
ATN2
CEILING
COS
COT
DEGREES
EXP
FLOOR
LOG
LOG10
PI
POWER
RADIANS
RAND
ROUND
SIGN
SIN
SQUARE
SQRT
TAN

String Functions
ASCII
CHAR
CHARINDEX
DIFFERENCE
LEFT
LEN
LOWER
LTRIM
NCHAR
PATINDEX
REPLACE
QUOTENAME
REPLICATE
REVERSE
RIGHT
RTRIM
SOUNDEX
SPACE
STR
STUFF
SUBSTRING
UNICODE
UPPER

Create a Stored Procedure
CREATE PROCEDURE name
@variable AS datatype = value
AS
–Comments
SELECT * FROM table
GO

Create a Trigger
CREATE TRIGGER name
ON
table
FOR
DELETE, INSERT, UPDATE
AS
–Comments
SELECT * FROM table
GO

Create a View
CREATE VIEW name
AS
–Comments
SELECT * FROM table
GO

Create an Index
CREATE UNIQUE INDEX name
ON
table(columns)

Create a Function
CREATE FUNCTION name
(@variable datatype(length))
RETURNS
datatype(length)
AS
BEGIN
DECLARE @return datatype(length)
SELECT @return = CASE @variable
WHEN ‘a’ THEN ‘return a’
WHEN ‘b’ THEN ‘return b’
ELSE ‘return c’
RETURN @return
END

 

How To Delegate Power Permissions In Windows XP

To grant the ability to change power management settings to limited users, edit the PowerCfg registry key.
This will set their power permissions similar to Power Users and allow limited users to adjust their own Power Options.

  1. Log in as Administrator
  2. Click Start then run
  3. In the run box type regedit
  4. In the registry editor search or drill down to:

HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg

  1. Right click on the PowerCfg folder anc click permissions
  2. Click the Advanced button to set special permissions
  3. Select Users under the Name column then click edit
  4. Set the permissions to look like the image
Windows XP Power Permissions
Windows XP Power Permissions
  1. Log Back in as limited user

Limited Users can now change their power options without bothering the Administrator.

With Windows XP past its end of life…it’s still going strong!

Estimates indicate Windows XP is still running on 160 – 250 million machines, around 14% of the world market share (6 % in the USA).

The reasons for running Windows XP are vast but most companies have hung on to Windows XP due to:

  • Application incompatibility with later versions of Windows.
  • The time involved in migrating thousands of XP machines.
  • The shear cost of such a migration.
  • Having to train employees and support staff on later versions of Windows.

Application compatibility is the one I witness most often. There is a large amount of custom enterprise software that will only run on Windows XP. Most software of this nature does not play well in Windows XP mode on Windows 7 and XP mode is not supported in later versions of Windows. Windows XP mode is basically a virtual machine running Windows XP inside another version of Windows. This can be accomplished on any version of Windows with any virtualization software. If a machine is currently running Windows XP its a waste of effort for System Administrator to setup a new PC with Windows 8 or 10 and then setup a virtual machine running Windows XP.

Most companies that fall into incompatibility area are utilities and other industrial companies. 75% of water utilities still have to run Windows XP.

Many manufacturing companies simply cannot afford the downtime of $100,000 to $1 million and hour. These companies need a Windows XP machine to run their production machines and their general view is that not being connected to an outside network, the security risk is minimal.

Kiosks and ATM machines make up another large portion of systems that run software that will only work on Windows XP machines. 95% of ATM machines run Windows XP and I would say that’s a fair estimate for kiosks as well

Even the United State’s Navy pays Microsoft $9 million (with a contract ceiling of $31 million) to continue to support Windows XP. The Navy is not the only branch of the armed forces or the United States Government to continue running Windows XP

Companies running Windows XP shouldn’t be a shock to any System Administrator, there are plenty of Government and financial institutions still running Windows 2000 and earlier Operating Systems. Windows 2003 Server is past it’s end and still commands 50% of Windows Servers in production.

At 14 years old, Windows XP continues to go strong. It is only #2, behind Windows 7 in world wide operating systems. Though unsupported and a huge security risk, I can see Windows XP living on for the next five to ten years.

How to install unsigned drivers in Windows 8.1

Microsoft did not implement Driver Signature Enforcement to annoy you. They did is to protect you from installing malicious software. This makes it a little more difficult for Rootkits to be installed on your PC. Be sure you know what you are installing!

The following steps will only last until you reboot your PC.

  1. Open Settings by clicking on your Start Screen or hitting the Windows key on your keyboard. Hover your mouse at the bottom right of the start screen until the sidebar appears. Click Settings.
  2. On the settings screen, click on Update and Recovery.
  3. On the Update and Recovery screen click Recovery.
  4. Click Restart Now under Advanced Startup.
    (Your PC will Restart into Advanced Boot Mode for this session only)
  5. Choose Troubleshoot from the Advanced Boot menu.
  6. Choose Advanced Options from the Troubleshoot menu.
  7. Choose Startup Settings from the Advanced Options Menu.
  8. Click Restart on the Startup Settings page.
    (Your PC will Restart with Advanced Startup Settings)
  9. From the Startup Settings menu choose: 7) Disable Driver Signature Enforcement.
    (Your PC will now fully boot up and Driver Signature Enforcement will be disabled for this session. Once you reboot or power down your PC Driver Signature Enforcement will be enabled.)
  10. Install your unsigned driver software. You will still get the Windows Security Alert (just click Install this driver software anyway)

Enjoy your software!