The post has moved to SAOSLab's blog on Microsoft Azure:
FFTSys Tech Blog on Azure Clound
Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts
Saturday, May 28, 2011
Wednesday, January 19, 2011
Blog is migrating
The post has moved here:
Sunday, January 2, 2011
Installing Latex on Windows and Linux and Latex Document Compilation Instructions
In this article, I’ll present some tips and tricks on how to do certain things on latex such as adding sections, subsections, inserting images and writing equations etc. Then I’ll provide a sample tex file and instructions for compiling the file using latex along with installation instructions of latex software on various operating systems.
Adding sections and subsections in latex documents
To add a section, use section tag. Here’s an example,
Adding sections and subsections in latex documents
To add a section, use section tag. Here’s an example,
\section{Overview} |
If this section is in a chapter it is preceded by a numbering. For example, if it is chapter 1 numbering is 1.1, 1.2 etc.
If you want to add a subsection under a section use use subsection tag. Here's an example,
It will have numbering like 1.1.1, 1.1.2 etc. If you need subsections under subsection, use subsubsection tag.
No more nesting (after 3 levels) is supported.
How to insert images on latex documents
The first thing you need to do is to convert your image (jpg, png, gif etc) to eps (a postscript format) which is easy to convert to pdf. To convert an image to eps format you need ImageMagick. In fedora installation command of ImageMagick is
In Windows you can install ImageMagick after downloading from http://www.imagemagick.org/download/binaries/
Current latest release direct link for Windows:
http://www.imagemagick.org/download/binaries/ImageMagick-6.6.6-7-Q16-windows-dll.exe
Now use the convert command to convert the image.
In widows you have to put the installation path as well with the command. For example, if it installed in C:\Program Files\ImageMagick directory.
To view eps files you need ghostscript. In Windows, you can install ghostscript from here:
http://ghostscript.com/releases/gs900w32.exe
In Fedora, you have to apply following command as root to install ghostscript,
Now it’s time to include the eps file on tex. Use figure tag to make caption, includegraphics command to include the image. You need to specify the correct path of your image in \includegraphics command. Here’s an example,
Set the caption text and label text same. Label text is used on List of figures. In a template they are automatically numbered according to chapter. If you need to scale up image to half of its size use scalebox tag along with includegraphics.
Writing scientific/math equations in latex
If your equations require numbering on right side use this tag,
For example,
But if your equation doesn’t require numbering use tag like this,
For example,
Integration symbol: \int
To show only root sign not n-th root use tag: \sqrt{x}, replace x with your expression or symbol
To show nth root use tag: \sqrt[n]{x}
To show fractions like ½ use \frac tag. Example,
For summation sign use \sum tag,
\limits is used to set limits on summation sign. Here, i=1 goes down and n goes up. You write texts preceding _ to put them down (subscript) and use ^ to superscript.
For using only one math symbol you can use \ensuremath{} tag. For example,
Here are latex tags for some of the math symbols:
You can find a detailed list of latex symbols here:
http://web.ift.uib.no/Teori/KURS/WRK/TeX/symALL.html
Installation Instructions of Latex for Fedora Core
Apply following commands after opening a terminal and logging into root. Alternatively you can apply su command and provide root password for instant switching.
Installation Instructions of Latex for Ubuntu
Apply following commands if you are using Ubuntu
Installation Instructions for Windows (XP, Vista, Seven)
Download basic-miktex from here: http://miktex.org/2.9/setup and run the installer.
Compiling Tex Documents
Now let’s learn how to compile latex document file. Here’s a sample tex file,
Open a text editor. Create a new file and paste the code given above. Save the file with name test.tex.
Now let’s compile the tex file. In Linux, apply following commands on terminal
A pdf file will be generated with same filename. In Linux if you need to view dvi files you can use either evince or xdvi
In Windows, you might skip generating dvi files. You can use pdflatex.
To compile tex files in Windows you need to apply following command,
assuming "C:\Program Files\TeX” is your installation directory for basic-miktex.
If there is no error on the tex file it will generate a pdf document which you can open using a pdf reader like Adobe pdf reader or Foxit Reader.
More tips and tricks
Here’s an example of using bullets for following texts:
Using tables
Follow this link: http://en.wikibooks.org/wiki/LaTeX/Tables It explains tables well.
Adding newlines: use \\ to add a newline
Using Bold styles: Use \textbf{text here} tag to bold your text.
Italicizing texts: You can use \emph tag or \textit tag to italicize your text. Example,
Subscripting: Write texts preceding _ to make them subscripted. To write xi type x_i
Superscript: use ^ to superscript. To write x^2 use x^2 exactly.
Troubleshooting
If you get errors like this frequently,
Latex expects including math tag during usage of math notations like superscript, subscript and symbols. Here’s an example,
When this syntax is ensured latex will not display those error messages anymore.
If you want to add a subsection under a section use use subsection tag. Here's an example,
\subsection{Formulation} |
It will have numbering like 1.1.1, 1.1.2 etc. If you need subsections under subsection, use subsubsection tag.
No more nesting (after 3 levels) is supported.
How to insert images on latex documents
The first thing you need to do is to convert your image (jpg, png, gif etc) to eps (a postscript format) which is easy to convert to pdf. To convert an image to eps format you need ImageMagick. In fedora installation command of ImageMagick is
# yum install ImageMagick |
In Windows you can install ImageMagick after downloading from http://www.imagemagick.org/download/binaries/
Current latest release direct link for Windows:
http://www.imagemagick.org/download/binaries/ImageMagick-6.6.6-7-Q16-windows-dll.exe
Now use the convert command to convert the image.
$ convert filename.jpg filename.eps |
In widows you have to put the installation path as well with the command. For example, if it installed in C:\Program Files\ImageMagick directory.
C:> “C:\Program Files\ImageMagick\convert.exe” filename.jpg filename.eps |
To view eps files you need ghostscript. In Windows, you can install ghostscript from here:
http://ghostscript.com/releases/gs900w32.exe
In Fedora, you have to apply following command as root to install ghostscript,
# yum install ghostscipt |
Now it’s time to include the eps file on tex. Use figure tag to make caption, includegraphics command to include the image. You need to specify the correct path of your image in \includegraphics command. Here’s an example,
1 \begin{figure}[htbp] 2 \centering 3 \includegraphics{./Figures/SA_Spheric.eps} 4 \caption{Latitude and Longitude \label{ Latitude and Longitude }} 5 \end{figure} |
Set the caption text and label text same. Label text is used on List of figures. In a template they are automatically numbered according to chapter. If you need to scale up image to half of its size use scalebox tag along with includegraphics.
\scalebox{0.5}{ \includegraphics{./Figures/SA_Spheric.eps}}
|
Writing scientific/math equations in latex
If your equations require numbering on right side use this tag,
\begin{equation} Your math exp \end{equation} |
For example,
\begin{equation}\int r = \sqrt[2]{x^2 + y^2 + z^2}\end{equation} |
But if your equation doesn’t require numbering use tag like this,
\begin{math} Your math exp \end{math} |
For example,
Our equation is, \begin{math}\int r = \sqrt[2]{x^2 + y^2 + z^2}\end{math}. Proof ... |
Integration symbol: \int
To show only root sign not n-th root use tag: \sqrt{x}, replace x with your expression or symbol
To show nth root use tag: \sqrt[n]{x}
To show fractions like ½ use \frac tag. Example,
thd = \frac{1}{n} |
For summation sign use \sum tag,
\sum\limits_{i = 1}^n Abs (t_i - t_{i-1})\end{equation} |
\limits is used to set limits on summation sign. Here, i=1 goes down and n goes up. You write texts preceding _ to put them down (subscript) and use ^ to superscript.
For using only one math symbol you can use \ensuremath{} tag. For example,
If angle in degree is \ensuremath{\theta} then the slope is .. |
Here are latex tags for some of the math symbols:
\Phi \lambda \Pi \epsilon |
You can find a detailed list of latex symbols here:
http://web.ift.uib.no/Teori/KURS/WRK/TeX/symALL.html
Installation Instructions of Latex for Fedora Core
Apply following commands after opening a terminal and logging into root. Alternatively you can apply su command and provide root password for instant switching.
$ su Password: # yum install tetex-latex evince-dvi xdvik |
Installation Instructions of Latex for Ubuntu
Apply following commands if you are using Ubuntu
# sudo apt-get install tetex-base tetex-bin |
Installation Instructions for Windows (XP, Vista, Seven)
Download basic-miktex from here: http://miktex.org/2.9/setup and run the installer.
Compiling Tex Documents
Now let’s learn how to compile latex document file. Here’s a sample tex file,
\documentclass[12pt]{article} \usepackage{amsmath} \title{\LaTeX} \date{} \begin{document} \maketitle \LaTeX{} is a document preparation system for the \TeX{} typesetting program. It offers programmable desktop publishing features and extensive facilities for automating most aspects of typesetting and desktop publishing, including numbering and cross-referencing, tables and figures, page layout, bibliographies, and much more. \LaTeX{} was originally written in 1984 by Leslie Lamport and has become the dominant method for using \TeX; few people write in plain \TeX{} anymore. The current version is \LaTeXe. % This is a comment; it is not shown in the final output. % The following shows a little of the typesetting power of LaTeX: \begin{align} E &= mc^2 \\ m &= \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}} \end{align} \end{document} |
Open a text editor. Create a new file and paste the code given above. Save the file with name test.tex.
Now let’s compile the tex file. In Linux, apply following commands on terminal
$ latex test.tex $ dvipdf test.dvi |
A pdf file will be generated with same filename. In Linux if you need to view dvi files you can use either evince or xdvi
$ evince test.dvi & $ xdvi test.dvi & |
In Windows, you might skip generating dvi files. You can use pdflatex.
To compile tex files in Windows you need to apply following command,
D:> "C:\Program Files\TeX\miktex\bin\pdflatex.exe" test.tex |
assuming "C:\Program Files\TeX” is your installation directory for basic-miktex.
If there is no error on the tex file it will generate a pdf document which you can open using a pdf reader like Adobe pdf reader or Foxit Reader.
More tips and tricks
Here’s an example of using bullets for following texts:
- Dining and canteen system
- Library, reading room system
- Debate,language club system
- Games and sports system
- Washing and cleaning system and Utensil management
\begin{itemize}
\item {Dining and canteen system}
\item {Library, reading room system}
\item {Debate,language club system}
\item {Games and sports system }
\item {Washing and cleaning system and Utensil management }
\end{itemize} |
Using tables
Follow this link: http://en.wikibooks.org/wiki/LaTeX/Tables It explains tables well.
Adding newlines: use \\ to add a newline
Using Bold styles: Use \textbf{text here} tag to bold your text.
Italicizing texts: You can use \emph tag or \textit tag to italicize your text. Example,
\emph{set your text here}
\textit{set your text here }
|
Subscripting: Write texts preceding _ to make them subscripted. To write xi type x_i
Superscript: use ^ to superscript. To write x^2 use x^2 exactly.
Troubleshooting
If you get errors like this frequently,
! Missing $ inserted. |
Latex expects including math tag during usage of math notations like superscript, subscript and symbols. Here’s an example,
\begin{math} Your expression for example C_i end{math} |
When this syntax is ensured latex will not display those error messages anymore.
Friday, August 27, 2010
Moved - Avro Keyboard 4.5.3 and UniBijoy
Moved to fftsys wp blog
Wednesday, August 18, 2010
Booting Solaris Operating System using Windows Boot Loader - redirect
The post has moved here:
http://tech.saoslab.com/post/2010/08/18/boot-solaris-windows-bcdedit-bootloader
http://tech.saoslab.com/post/2010/08/18/boot-solaris-windows-bcdedit-bootloader
Blog is migrating
The post has moved here:
Why micrsoft.com doesn’t reply to ping
[sa@localhost ]$ ping www.microsoft.com
Pinging lb1.www.ms.akadns.net [65.55.21.250] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 65.55.21.250:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
|
Do you know why Micrsoft.com doesn’t replies to ping?
ping is a powerful small command line tool. Seeing the output of ping command a security analyst or hacker can grab important information about the target hosts. Target hosts can be web servers or a pc on local area network. Information includes Operating System & Version, availability of host etc.
Wednesday, May 5, 2010
Windows Seven: "Windows could not start the Windows Event Log Service on Local Computer" and winsock
Today I sat on my PC like other days. It took long time to boot into The Windows Seven Desktop. When it booted it showed an error notification.
"Failed to connect to a windows service - Windows could not connect to the System Event Notification service. This problem prevents limited users from logging on to the system. As an administrator user, you can review the System Event Log for details about why the service didn't respond."
So I tried to enable system event log service myself from services.msc. It reported another error!
Windows could not start the Windows Event Log Service on Local Computer
Error 1747: the authentication service is unknown.
Also I got an error when trying to activate network interface.
Unable to Initialize Windows Sockets Interface
I tried manythings. Like I was thinking if Kaspersky Internet Security has got the control. So uninstall it. Tried to enable, disable couple of services. Nothing solved it.
Finally the trick of resetting socket interface really worked. To reset the socket interface I opened a command prompt by clicking run as administrator. Then applied the following command.
Then I restarted the PC. Everything got fixed. It saved the day.
"Failed to connect to a windows service - Windows could not connect to the System Event Notification service. This problem prevents limited users from logging on to the system. As an administrator user, you can review the System Event Log for details about why the service didn't respond."
So I tried to enable system event log service myself from services.msc. It reported another error!
Windows could not start the Windows Event Log Service on Local Computer
Error 1747: the authentication service is unknown.
Also I got an error when trying to activate network interface.
Unable to Initialize Windows Sockets Interface
I tried manythings. Like I was thinking if Kaspersky Internet Security has got the control. So uninstall it. Tried to enable, disable couple of services. Nothing solved it.
Finally the trick of resetting socket interface really worked. To reset the socket interface I opened a command prompt by clicking run as administrator. Then applied the following command.
C:> netsh winsock reset |
Then I restarted the PC. Everything got fixed. It saved the day.
Monday, January 18, 2010
Windows command prompt pwd command doesn't work
There is no pwd executable file in windows. But there is a way. Create a batch script with following texts.
@echo %CD% |
Save it as pwd.cmd. Now type pwd command at command prompt.
st> pwd g:\Sourcecodes\Scripts |
Also you can type cd without any arguments which works the same way as pwd in Linux.
Monday, January 4, 2010
OpenGL on Windows & Common Instructions
Download glut for Windows here here.
Common instructions for setting up opengl with Visual Studio
Many different sites have posts about this. However, I'm going to give you hints. In Pro versions SDKs are installed by default. If you are using Visual Studio Express you need to install Windows Platform SDK.
Now extract the glut archive you just downloaded from this page. Copy glut.h and paste where GL.h and GLU.h resides.
Now extract the glut archive you just downloaded from this page. Copy glut.h and paste where GL.h and GLU.h resides.
The directory is PlatformSDKInstallDIR\Windows\VERSION\Include\gl
Copy dll file to System 32 folder
Copy lib file to to PlatformSDKInstallDIR\Windows\VERSION\Lib
For Visual Studio 2008 Pro files go like this.
glut.h -> C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl
glut32.dll-> C:\Windows\System32
glut32.lib -> C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
Testing OpenGL Code
- Create new win32 -> win32 project.
- Click Solution Explorer. Right click Source Files. Click Add - > New Item. Specify a name. Select .cpp as template.
- Download this code file. Extract and copy the contents of the cpp file and paste on the empty cpp file of the IDE
- Select Project properties additional dependency: opengl32.lib glut32.lib glu32.lib
- To build press Alt + Shft + B. If build is successful press Ctrl + F5 to run the program.
Example of such code here.
Related Links:
Tuesday, December 22, 2009
How to Install Windows XP without Deleting Linux Partition
You try to start installation of Windows XP from a bootable CD/DVDROM. It displays a message saying “Setup is inspecting your computer's hardware configuration” and after a while screen goes black. It seems like as if the installation procedure hanged up.
It happens when you have a Linux partition (mostly ext3) in your disk (HDD). Easiest way is to avoid Windows XP. For example, Windows Vista and Seven doesn’t have this requirement that hard-disk should not contain a Linux partition. You can install them flawlessly.
If it is strictly required that you should install Windows XP, if you don’t need Linux anymore you can delete those Linux partitions from disk management (Right click My Computer -> click Manage -> click Disk Management and you go there).
It happens when you have a Linux partition (mostly ext3) in your disk (HDD). Easiest way is to avoid Windows XP. For example, Windows Vista and Seven doesn’t have this requirement that hard-disk should not contain a Linux partition. You can install them flawlessly.
If it is strictly required that you should install Windows XP, if you don’t need Linux anymore you can delete those Linux partitions from disk management (Right click My Computer -> click Manage -> click Disk Management and you go there).
But if you require to install Windows XP and to keep the Linux unaffected at the same time this is what this page is mainly about.
If you can access Windows in your computer then try first solution. But if you cannot access Windows or want to fix it up using Linux even if you cannot boot into Linux for bootloader problem try second solution.
You need a gnu utility called testdisk to do this. Thanks GNU for their nicest work. Download testdisk from here.
http://www.cgsecurity.org/wiki/TestDisk_Download
If you can access Windows in your computer then try first solution. But if you cannot access Windows or want to fix it up using Linux even if you cannot boot into Linux for bootloader problem try second solution.
You need a gnu utility called testdisk to do this. Thanks GNU for their nicest work. Download testdisk from here.
http://www.cgsecurity.org/wiki/TestDisk_Download
First Solution
- For Windows you should click Windows on the download page and then complete the download.
Unzip the downloaded file.
Go the testdisk directory. Enter into win directory.
Double click testdisk_win.exe.
- If you have more than one hard-disk select the hard-disk containing Operating Systems first.
- Now select “proceed” and then pres enter. [pressing left or right arrow key selects an option].
- Select Intel (if you are using other system you know it) and then press enter.
- Select analyse and hit enter.
- Let’s first keep a back of the existing partition table.
Select Backup and then press enter.
- Press ‘n’ if you were not using Windows Vista/Seven to create partitions and hit enter.
Select quick search and then press enter. Testdisk will now be searching for lost partitions. Don’t worry about that.
And finally it you will be complete and a list of partitions will be displayed.
- We are temporarily going to delete Linux entries from partition table. Select every Linux partition and press left/right arrow key to change their status. Make them D as shown in image above. Please be careful in this step.
And then press enter. Updated list of partitions will be displayed.
- Now select write as shown in image and then press enter.
- It will ask for confirmation. Press ‘y’ and then enter.
After restart you will be able to install Windows XP. - After installation run testdisk again. Follow the steps same like first solution but select quick search this time and hit enter key.
- Press l to load back up in partition list window. Following screen will be displayed.
- Select load and hit enter.
- Partition list will be displayed again. Hit enter. Now select write. And then y and then enter again. Now your linux partitions are back. To fix linux bootloader now follow this link.
http://sa-os.blogspot.com/2009/11/linux-gone-after-installing-windows.html
Second Solution
If you have Linux in your disk but cannot boot into then check this link out to recover your linux bootloader.
http://sa-os.blogspot.com/2009/11/linux-gone-after-installing-windows.html
After booting into your Linux system. Download the linux version of testdisk (rpm for Fedora Core, Suse, RHEL, CentOS and .tar.bz2 for other versions) you will have to type testdisk in a terminal after loggin in as root or doing an su.
Now follow the steps described in first solution starting from running testdisk.
N.B: Be careful about losing data giving wrong commands or committing mistakes. We suggest you to keep backup of your essential data.
If you face a problem still write in comments.
[Copy-right material. Contents of this post shouldn’t be copied to any other website for any kind of profit without permission. Contact unix9n at gmail dot com]
http://sa-os.blogspot.com/2009/11/linux-gone-after-installing-windows.html
After booting into your Linux system. Download the linux version of testdisk (rpm for Fedora Core, Suse, RHEL, CentOS and .tar.bz2 for other versions) you will have to type testdisk in a terminal after loggin in as root or doing an su.
Now follow the steps described in first solution starting from running testdisk.
N.B: Be careful about losing data giving wrong commands or committing mistakes. We suggest you to keep backup of your essential data.
If you face a problem still write in comments.
[Copy-right material. Contents of this post shouldn’t be copied to any other website for any kind of profit without permission. Contact unix9n at gmail dot com]
Sunday, December 6, 2009
Win32 Programming: How to Disable Unicode
It seems to be a mess for traditional C programmers to start with win32 when Unicode is enabled! All the texts, preceded `L` or `_T` are abstruse. Also most functions they are accustomed with doesn’t work because of incompatibility of data types and gives so many errors. What if we could disable Unicode and write program easily as most programs/software doesn’t strictly require to be Unicode!
We need to make a little change in project configuration. Open your project in Visual Studio IDE. Press Alt + F7.
There is an option named “General” under Configuration properties in the right side of the dialog box. Click it.
Under ‘project defaults’, there is a property called ‘Character Set’. Change its value from “Use Unicode Character Set” to “Use Multi-Byte Character Set” selecting from the drop down list as shown in the image below. Click the image to enlarge.
We need to make a little change in project configuration. Open your project in Visual Studio IDE. Press Alt + F7.
There is an option named “General” under Configuration properties in the right side of the dialog box. Click it.
Under ‘project defaults’, there is a property called ‘Character Set’. Change its value from “Use Unicode Character Set” to “Use Multi-Byte Character Set” selecting from the drop down list as shown in the image below. Click the image to enlarge.
Now you can use normal string functions like strlen, sprintf etc in this program to manipulate strings. Here is a sample program demonstrating ANSI C behavior.
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
static TCHAR szWindowClass[] = "win32app";
static TCHAR szTitle[] = "SA OS Win32 Tutorial";
HINSTANCE hInst;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
"Call to RegisterClassEx failed!",
"Win32 Tutorial",
NULL);
return 1;
}
hInst = hInstance;
HWND hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
300, 280,
NULL,
NULL,
hInstance,
NULL
);
if (!hWnd)
{
MessageBox(NULL,
"Call to CreateWindow failed!",
"Win32 Guided Tour",
NULL);
return 1;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
char *inst = "Non-unicode program";
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
TextOutA(hdc, 25, 75, inst, strlen(inst));
inst = new char[101];
sprintf_s(inst, 100, "Length of the string: %d", strlen(inst));
TextOutA(hdc, 25, 95, inst, strlen(inst));
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
Win32 Programming Quick Start Tutorial
To write win32 programs good idea is to use Visual Studio. It is indeed a good IDE with syntax highlighting, compiler, linker along with other features. I wrote and tested all programs in Visual Studio 2008 Professional. You can get this software from here. After downloading extract it and install.
You have to write programs creating new win32 projects. If you don’t know how to create project follow here.
WinMain Function
Win32 programs are different from ANSI C programs. There are lots of information about GUI to maintain with. Though WinAPI is strong & featureful they are bit lowlevel. They don’t have a main function. Instead they have winMain which have 4 parameters. Also return type is different. Here is the syntax:
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow);
Short Description of Parameters
hInstance
Handle to the current instance of the application.
hPrevInstance
Handle to the previous instance of the application.
lpCmdLine
Command line String.
nCmdShow
Specifies how the window is to be shown. This parameter can be one of the following values.
SW_HIDE
Hides the window and activates another window.
SW_MAXIMIZE
Maximizes the specified window.
SW_MINIMIZE
Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE
Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW
Activates the window and displays it in its current size and position.
etc..
CALLBACK Function (Windows Procedure)
To handle messages from Operating System a windows procedure is used. Actually we can give it any name and specify in the WNDCLASS class property. In our case it is WndProc.
Syntax:
Here is a tested program that will help you to start with. The program is well-documented.
// win32_tutorial_01.cpp
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
// Global variables
// The main window class name.
static TCHAR szWindowClass[] = _T("win32app");
// The string that appears in the application's title bar.
static TCHAR szTitle[] = _T("SA OS Win32 Tutorial");
HINSTANCE hInst;
// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// A class used to store general information about this application
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
// On registration failure show error and exit
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("Win32 Tutorial"),
NULL);
return 1;
}
hInst = hInstance; // Store instance handle in our global variable
// The parameters to CreateWindow explained:
// szWindowClass: the name of the application
// szTitle: the text that appears in the title bar
// WS_OVERLAPPEDWINDOW: the type of window to create
// CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
// 500, 100: initial size (width, length)
// NULL: the parent of this window
// NULL: this application dows not have a menu bar
// hInstance: the first parameter from WinMain
// NULL: not used in this application
HWND hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
300, 280,
NULL,
NULL,
hInstance,
NULL
);
if (!hWnd)
{
MessageBox(NULL,
_T("Call to CreateWindow failed!"),
_T("Win32 Guided Tour"),
NULL);
return 1;
}
// The parameters to ShowWindow explained:
// hWnd: the value returned from CreateWindow
// nCmdShow: the fourth parameter from WinMain
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
char *inst = "Welcome to win32 programming.";
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// Here your application is laid out.
// For this introduction, we just print out "Hello, World!"
// in the top left corner.
TextOutA(hdc, 25, 85, inst, strlen(inst));
// End application-specific layout section.
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
Press Ctrl + Shift + B to Build the program and then Ctrl + F5 to run the program. Download project files from here in case you cannot build and test the code yourself successfully.
Some Basics
And _T() macro is used to set L before a string to represent Unicode string. The purpose of TEXT() macro is also the same.
"P" means "pointer"
"W" means "wide"
"L" means "LONG"
"STR" means "string"
"C" means "const"
Hence,
PWSTR means "pointer of wide string", that is, unsigned short* (or wchar_t*)
LPSTR means "long pointer of string", that is, char*
WCHAR means "wide char", that is, unsigned short (or wchar_t)
LPCSTR means "const pointer of string", that is, const char* (Value assigned once cannot be altered at all)
When you are done with this program, check these links to complete your knowledge.
WinMain on msdn
WindowProc on msdn
Windows Data Types
MSDN is the main source of all WinAPI programming references. Hence, match in contents is acknowledged here. When you need to understand how a winAPI function works or detail info on that go to msdn and perform a search providing the exact function name. Have fun with Windows OS.
Continue to next tips & tricks.
You have to write programs creating new win32 projects. If you don’t know how to create project follow here.
WinMain Function
Win32 programs are different from ANSI C programs. There are lots of information about GUI to maintain with. Though WinAPI is strong & featureful they are bit lowlevel. They don’t have a main function. Instead they have winMain which have 4 parameters. Also return type is different. Here is the syntax:
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow);
Short Description of Parameters
hInstance
Handle to the current instance of the application.
hPrevInstance
Handle to the previous instance of the application.
lpCmdLine
Command line String.
nCmdShow
Specifies how the window is to be shown. This parameter can be one of the following values.
SW_HIDE
Hides the window and activates another window.
SW_MAXIMIZE
Maximizes the specified window.
SW_MINIMIZE
Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE
Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW
Activates the window and displays it in its current size and position.
etc..
CALLBACK Function (Windows Procedure)
To handle messages from Operating System a windows procedure is used. Actually we can give it any name and specify in the WNDCLASS class property. In our case it is WndProc.
Syntax:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);Here is a tested program that will help you to start with. The program is well-documented.
// win32_tutorial_01.cpp
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
// Global variables
// The main window class name.
static TCHAR szWindowClass[] = _T("win32app");
// The string that appears in the application's title bar.
static TCHAR szTitle[] = _T("SA OS Win32 Tutorial");
HINSTANCE hInst;
// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// A class used to store general information about this application
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
// On registration failure show error and exit
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("Win32 Tutorial"),
NULL);
return 1;
}
hInst = hInstance; // Store instance handle in our global variable
// The parameters to CreateWindow explained:
// szWindowClass: the name of the application
// szTitle: the text that appears in the title bar
// WS_OVERLAPPEDWINDOW: the type of window to create
// CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
// 500, 100: initial size (width, length)
// NULL: the parent of this window
// NULL: this application dows not have a menu bar
// hInstance: the first parameter from WinMain
// NULL: not used in this application
HWND hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
300, 280,
NULL,
NULL,
hInstance,
NULL
);
if (!hWnd)
{
MessageBox(NULL,
_T("Call to CreateWindow failed!"),
_T("Win32 Guided Tour"),
NULL);
return 1;
}
// The parameters to ShowWindow explained:
// hWnd: the value returned from CreateWindow
// nCmdShow: the fourth parameter from WinMain
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
char *inst = "Welcome to win32 programming.";
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// Here your application is laid out.
// For this introduction, we just print out "Hello, World!"
// in the top left corner.
TextOutA(hdc, 25, 85, inst, strlen(inst));
// End application-specific layout section.
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
Press Ctrl + Shift + B to Build the program and then Ctrl + F5 to run the program. Download project files from here in case you cannot build and test the code yourself successfully.
Some Basics
And _T() macro is used to set L before a string to represent Unicode string. The purpose of TEXT() macro is also the same.
"P" means "pointer"
"W" means "wide"
"L" means "LONG"
"STR" means "string"
"C" means "const"
Hence,
PWSTR means "pointer of wide string", that is, unsigned short* (or wchar_t*)
LPSTR means "long pointer of string", that is, char*
WCHAR means "wide char", that is, unsigned short (or wchar_t)
LPCSTR means "const pointer of string", that is, const char* (Value assigned once cannot be altered at all)
When you are done with this program, check these links to complete your knowledge.
WinMain on msdn
WindowProc on msdn
Windows Data Types
MSDN is the main source of all WinAPI programming references. Hence, match in contents is acknowledged here. When you need to understand how a winAPI function works or detail info on that go to msdn and perform a search providing the exact function name. Have fun with Windows OS.
Continue to next tips & tricks.
How to Activate Windows Seven / Vista Administrator Account
First, open Command Prompt. Go to Start Menu> All Programs> Accessories
Right click Command Prompt and click 'Run as administrator'.
Now type in the prompt:
And set a password for the account
Use your password instead of the keyword 'YourPassword'. It was damn easy. Isn't it?
To deactivate use no instead of yes
Right click Command Prompt and click 'Run as administrator'.
Now type in the prompt:
C:> net user administrator /active:yes |
And set a password for the account
C:> net user administrator YourPassword |
Use your password instead of the keyword 'YourPassword'. It was damn easy. Isn't it?
To deactivate use no instead of yes
C:> net user administrator /active:no |
Tuesday, November 10, 2009
How to Remove Conflickr/ DownAdUp Worm
If you are running a Windows Operating System with a safe browser like Google Chrome or Mozilla Firefox and you're thinking that you are very safe from worms/viruses then I'd ve to say you're in fool's paradise. If you are connected using a LAN to your ISP then there's high chance to be affected with worms whose creators really cared about vulnerabilities in Windows TCP/IP network.
If you cannot access antivirus websites and microsoft.com site but others then you are already affected with Conflickr Worm. Kido.h and kido.ir worms will be copied in your USB pen drive(though the worm allows safele remove hardware) and they'll be detected by antivirus on other PCs which are not affected. If you are not affected and you are using Windows urgently install these update not to be affected:
http://www.microsoft.com/downloads/details.aspx?familyid=0D5F9B6E-9265-44B9-A376-2067B73D6A03&displaylang=en
http://www.microsoft.com/downloads/details.aspx?FamilyId=2996b9b6-03ff-4636-861a-46b3eac7a305&displaylang=en
Conflickr worm is brilliantly dangerous because before I didn’t know a worm that’d exploit into PC using local area network implementing a weakness (TCP/IP Buffer Overflow) of Windows Operating System.
If you are affected with this worm install Malicious Software Removal Tool to remove conflickr worm. That’s the tool actually works as people tested.
Download Microsoft® Windows® Malicious Software Removal Tool (KB890830) from here:
From microsoft.com
Or from mediafire.com
More info on this tool here:
http://www.microsoft.com/security/malwareremove/default.aspx
Also there is a tool from Symantec that you can try out in case:
http://www.symantec.com/content/en/us/global/removal_tool/threat_writeups/D.exe
After restarting ping to kaspersky.com Symantec.com etc. If they work you are one step behind from being safe. Now update your antivirus database definitions and run a full harddisk scan.
If you are interested about this worm you’ll get great deal of information about this here:
Microsoft Tips and Tricks along with info to prevent this worm
About The Malicious Software Remover Tool
Manual Removal Instructions and more info from Microsoft [Download this page from mediafire]
If you cannot access antivirus websites and microsoft.com site but others then you are already affected with Conflickr Worm. Kido.h and kido.ir worms will be copied in your USB pen drive(though the worm allows safele remove hardware) and they'll be detected by antivirus on other PCs which are not affected. If you are not affected and you are using Windows urgently install these update not to be affected:
http://www.microsoft.com/downloads/details.aspx?familyid=0D5F9B6E-9265-44B9-A376-2067B73D6A03&displaylang=en
http://www.microsoft.com/downloads/details.aspx?FamilyId=2996b9b6-03ff-4636-861a-46b3eac7a305&displaylang=en
Conflickr worm is brilliantly dangerous because before I didn’t know a worm that’d exploit into PC using local area network implementing a weakness (TCP/IP Buffer Overflow) of Windows Operating System.
If you are affected with this worm install Malicious Software Removal Tool to remove conflickr worm. That’s the tool actually works as people tested.
Download Microsoft® Windows® Malicious Software Removal Tool (KB890830) from here:
From microsoft.com
Or from mediafire.com
More info on this tool here:
http://www.microsoft.com/security/malwareremove/default.aspx
Also there is a tool from Symantec that you can try out in case:
http://www.symantec.com/content/en/us/global/removal_tool/threat_writeups/D.exe
After restarting ping to kaspersky.com Symantec.com etc. If they work you are one step behind from being safe. Now update your antivirus database definitions and run a full harddisk scan.
If you are interested about this worm you’ll get great deal of information about this here:
Microsoft Tips and Tricks along with info to prevent this worm
About The Malicious Software Remover Tool
Manual Removal Instructions and more info from Microsoft [Download this page from mediafire]
Labels:
Antivirus,
Virus/Worm Removal,
Windows,
Windows Seven
Friday, October 16, 2009
Google Chrome Latest Releases Direct Download Links and Google Search Tips & Tricks
Google Chrome Latest Stable and Beta Releases without Google Updater
Google Chrome is an open-source browser which doesn't require a introduction now. Still it is a light-weight fast web browser that now supports themes.
Also it has some intelligent things integrated with. For example, all google search syntax can be applied on the address bar.
The most significant thing I like about google chrome in first is it's powerful virtual machine. Did you notice the load time of New Yahoo Mail and Gmail in Chrome? It's damn faster. Every site with javascript and other rendering contexts will load faster in chrome. We spend most of our time in web browser than other applications. If our pageloads take longer time just sum of wasted valuable time gets huge. So the suggestion is use Google Chrome, save your time.
With Google Chrome 4 you can use many themes as well as huge set of extensions.
With Google Chrome 4 you can use many themes as well as huge set of extensions.
You can save more of your time by directly typing search queries on address bar. If you want the definition of word technology type in the address bar "define: technology" (without the quotations).
You want to know the time type location preceded by time like this "time Bangladesh".
You want to know to do some calculations you can do that easily "2 + 2 = "
Need to know about weather? Type like this "weather Dhaka, Bangladesh"
You want to know to do some calculations you can do that easily "2 + 2 = "
Need to know about weather? Type like this "weather Dhaka, Bangladesh"
Curious? Want to know more about Google Search Features? Click here. Users who are using other browsers like Mozilla Firefox can use these syntaxes in google web search site. Note this post will be updated with latest releases of Google Chrome. So you can bookmark if it helps. To Download Google Chrome full installer from google's server click on links below:
Download Latest Development Release
Linux users follow this link:
Instruction for Installing Google Chrome on Linux
Related Links:
Google Chrome Home PageGoogle's Official Chrome Release Blog
Google search Features
Google search basics
Sunday, October 4, 2009
All Bangla Solutions for your Operating System
Please follow post here.
Subscribe to:
Comments (Atom)

















