Wednesday, June 8, 2011

Windows Genuine устгах

Windows суулгахаар update хийх бичиг гарч ирдэг дээ. Хүмүүс анзааралгүй update хийгээд Genuine гэгчийг суулгачихдаг.  Genuine-с салах аргыг орууллаа.

1.run-cmd-regedit гэж ороод HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify гэсэн folder-г устга

2.Тэгээд PC-гээ restart хий

3.Тэгээд C:\Windows\System32 дотор WgaTray.exe,WgaTray.dll гэж 2 file байгаа тэрийг олоод устга

4.C:\Windows\System32\dllcache\ дотор WgaTray.exe,WgaTray.dll бас байгаа олж устгаад л боллоо.  dllcache folder чинь hide байгаа учир folder option-с нээгээрэй.

Saturday, February 19, 2011

Жава жишээ

Increment, decrement operatorууд
Java-д Стэй адил ++ болон – operator-ууд байдаг.
Increment operators
class Count {
public static void main (String args[]) {
for (int i = 0; i < 50; i++) {
System.out.println(i);
}
}
}

Decrement operators
class Count {
public static void main (String args[]) {
for (int i = 50; i > 0; i--) {
System.out.println(i);
}
}
}

Print statements
class PrintArgs {
public static void main (String args[]) {
for (int i = 0; i < args.length; i++) {
System.out.println(args[i]);
}
}
}
$ java PrintArgs Hello there!
Hello there!
System.out.println() нь аргументуудаа хэвлэнэ. Аргументуудыг println() болон (+) тусламжтайгаар холбодог. System.out.println("There are " + args.length + " command line arguments"); print()-г println()-н оронд хэрэглэвэл мөр шилжихгүй хэвлэнэ.

Жишээ нь,
System.out.print("There are ");
System.out.print(args.length);
System.out.print(" command line arguments");
System.out.println();
System.out.println() бол мөр шилжүүлж, гаралтын үр дүнг шууд гаргана.

Fibonacci Numbers
class Fibonacci {
public static void main (String args[]) {
int low = 0;
int high = 1;
while (high < 50) {
System.out.println(high);
int temp = high;
high = high + low;
low = temp;
}
}
}

Жишээ
while loop хувьсагч зарлах ба утга оноох
for loops
class Count {
public static void main (String args[]) {
int i;
for (i = 0; i < 50; i=i+1) {
System.out.println(i);
}
}
}

Java points, object, class-n талаар


Үүнд field хариулна харин мethod бол oбъектын юу хийхийг заана.
class TwoDPoint {
double x;
double y;
}
Энэ class-г compile хийхийн тулд үүнийгээ TwoDPoint.java файлд хадгална. Дараа нь:
$ javac TwoDPoint.java
Үүний үр дүнд юу үүсэх вэ? Энэ бүтэн програм мөн үү? Энэ ажиллах уу?

Oбъектууд
Объект гэж юу вэ?
Constructor бүхий new түлхүүр үгийн тусламжтайгаар объект үүсгэнэ. Жишээ нь, дараах програм TwoDPoint oбъектийг үүсгэх ба field-г нь хэвлэнэ.
class OriginPrinter {
public static void main(String[] args) {
TwoDPoint origin; // only declares, does not allocate
// The constructor allocates and usually initializes the object
origin = new TwoDPoint();
// set the fields
origin.x = 0.0;
origin.y = 0.0;
// print the two-d point
System.out.println(
"The origin is at " + origin.x + ", " + origin.y);
} // end main
} // end OriginPrinter
. бол member access separator.
new орсон бол объектийг заавал хуваарилах шаардлагатай болдог. Энэ class-г compile хийхийн тулд OriginPrinter.java нэрээр TwoDPoint.java-тай 1 директорт хадгална. 
$ javac OriginPrinter.java
Үүний үр дүнд юу үүсэх вэ? Энэ бүтэн програм мөн үү? Энэ ажиллах уу?

Олон объектууд
Ерөнхийдөө ямар нэг class-н хувьд нэгээс олон объект байдаг. Reference хувьсагчуудыг ижил class дах өөр өөр объектуудыг ялгахын тэлд хэрэглэдэг.
Жишээ: Доорх программ 2 ширхэг two-d point объектийг үүсгэж, тэдгээрийн field-үүдийг хэвлэнэ.
class TwoPointPrinter {
public static void main(String[] args) {
TwoDPoint origin; // only declares, does not allocate
TwoDPoint one; // only declares, does not allocate
// The constructor allocates and usually initializes the object
origin = new TwoDPoint();
one = new TwoDPoint();
// set the fields
origin.x = 0.0;
origin.y = 0.0;
one.x = 1.0;
one.y = 0.0;
// print the 2D points
System.out.println(
"The origin is at " + origin.x + ", " + origin.y);
System.out.println("One is at " + one.x + ", " + one.y);
} // end main
} // end TwoPointPrinter
one болон origin бол 2 өөр point объектийг зааж байгаа 2 өөр reference хувьсагч юм. Дээрх жишээний x, y шиг хувьсагчийг class- ын гишүүнээр таних нь хангалтгүй, class-ын аль объектэд хандаж байгаагаа зааж өгөх хэрэгтэй. 2 өөр reference хувьсагч ижил объектийг заах боломжтой. Объектийг ямар нэг reference хувьсагч хэрэглэхгүй болсон үед уг объект garbage collection руу илгээгдэнэ. Жишээлбэл, дараах программ 2 TwoDPoint reference хувьсагчийг
зарлан, 1 two-d point объектийг үүсгэж, уг объектийг 2 хувьсагчид оноож өгдөг. Энэ үед уг 2 хувьсагч тэнцүү байна.
class EqualPointPrinter {
public static void main(String[] args) {
TwoDPoint origin1; // only declares, does not allocate
TwoDPoint origin2; // only declares, does not allocate
// The constructor allocates and usually initializes the object
origin1 = new TwoDPoint();
origin2 = origin1;
// set the fields
origin1.x = 0.0;
origin1.y = 0.0;
// print
System.out.println(
"origin1 is at " + origin1.x + ", " + origin1.y);
System.out.println(
"origin2 is at " + origin2.x + ", " + origin2.y);
} // end main
} // end EqualPointPrinter
origin1, origin2 бол 1 ижил point объектд хамаарах 2 өөр reference хувьсагчууд юм.

Static Field-үүд
Static эсвэл class field-үүд объект-д биш тодорхой 1 class-т хамаардаг.
class Point {
double x;
double y;
static double xorigin = 0.0;
static double yorigin = 0.0;
}
System.out.println("The origin is at (" + Point.xorigin + ", " + Point.yorigin + ")");

Жава Method-ууд


Method-ууд объектийн юу хийхийг заадаг.
class TwoDPoint {
double x;
double y;
void print() {
System.out.println(this.x + "," + this.y);
}
}
Java-н this гэсэн түлхүүр үг ижил class-н дотроос field-г зааж байна.
TwoDPoint origin = new TwoDPoint();
origin.x = 0.0;
origin.y = 0.0;
origin.print();

Аргументуудыг мethod руу дамжуулах
class TwoDPoint {
double x;
double y;
void print() {
System.out.println("(" + this.x + "," + this.y + ")");
}
void print(int n) {
for (int i = 0; i < n; i++) {
System.out.println("(" + this.x + "," + this.y + ")");
}
}
TwoDPoint origin = new TwoDPoint();
origin.x = 0.0;
origin.y = 0.0;
origin.print(10);
2 өөр print() method байгааг анхаар. 1 нь аргументийг авдаг бол нөгөөх нь үгүй. Аргументууд сонголтыг тодорхой болгож байгаа учраас энэ нь OK. Үүнийг overloading гэж нэрлэнэ. Бидний хэрэглэж байгаа System.out.println() бол overloaded method юм. main(String[] args) бол non-overloaded method бөгөөд string массивыг aргументаараа авдаг.
Method-с утга буцааж авах
class TwoDPoint {
double x;
double y;
void print() {
System.out.println("(" + this.x + "," + this.y + ")");
}
String getAsString() {
return "(" + this.x + "," + this.y + ")";
}
}
TwoDPoint origin = new TwoDPoint();
origin.x = 0.0;
origin.y = 0.0;
String s = origin.getAsString();
System.out.println(s);
Сайн байна
TwoDPoint origin = new TwoDPoint();
origin.x = 0.0;
origin.y = 0.0;
System.out.println(origin.getAsString());

setter method
Энэ method-ууд field-ын утгыг class-т олгодог.
class TwoDPoint {
double x;
double y;
String getAsString() {
return "(" + this.x + "," + this.y + ")";
}
void setX(double value) {
this.x = value;
}
void setY(double value) {
this.y = value;
}
}
TwoDPoint origin = new TwoDPoint();
origin.setX(0.0);
origin.setY(0.0);
System.out.println(origin.getAsString());

getter method
accessor method гэж нэрлэгддэг ба getter method-ууд field-ын утгыг class-т олгодог.
class TwoDPoint {
double x;
double y;
String getAsString() {
return "(" + this.x + "," + this.y + ")";
}
void setX(double value) {
this.x = value;
}
void setY(double value) {
this.y = value;
}
double getX() {
return this.x;
}
double getY() {
return this.y;
}
}
TwoDPoint origin = new TwoDPoint();
origin.setX(0.0);
origin.setY(0.0);
System.out.println("The x coordinate is " + origin.getX());