Wednesday, December 29, 2010

Difference Between Virtual and Cache memory

Nowadays memory seems to be almost infinite and nobody actually gets the “not enough memory” messages of yester-year. How did they accomplish that?
The answer to that is a very smart memory management procedure. By placing some parts that should be in memory inside your hard-disk they can extend the memory capacity of a computer way beyond what is installed; this is called virtual memory. So let’s say that your computer only has 1GB of memory and you launch a few programs whose total memory consumption is at around 1.5GB. Without virtual memory, you are not allowed to do that. But with virtual memory, the operating system assigns a portion of the hard-disk as a part of memory and keeps the data there. So in the above example let’s say that the virtual memory is also 1GB. 1GB actual memory + 1GB virtual memory = 2GB system memory. That way even though your memory is limited you can still use memory extensive applications.
There is a disadvantage to virtual memory though. Reading data from a hard disk is substantially slower than reading from memory. So the more information that is stored in your hard-disk the slower your system becomes making it seem sluggish.


Cache memory on the other hand doesn’t extend the amount of memory you have, it merely lessens the amount of time needed to access data. So that you can understand the concept easily, let’s say that the processor is a student doing a report. Whenever he needs data he goes to the bookshelf (the bookshelf being the memory, and the books are the data) ,that is called Cache memory.

SAP memory vs ABAP memory

ABAP (Advanced Business Application Programming) programs run on a SAP database. ABAP programs can utilize two types of memory, ABAP memory and SAP memory. The main difference between these two types of memory is their scope. ABAP memory is pretty limited and can only be accessed within one main internal session. Other programs running outside that session will not be able to read or write to that memory. On the other hand, SAP memory is pretty much like global memory and is accessible not only by programs that are running under the same main session but also across different main sessions.
The different scopes between the two lead to two different uses. The main use of ABAP memory is to make data accessible across multiple transactions within the same session. Although SAP memory is also capable of performing this function, it is reserved for its own purpose; making information available or transferring data across main session.

Summary:
  1. SAP memory is global and can be used to pass data across main sessions while ABAP memory is local and is uses to pass data across internal sessions
  2. GET PARAMETER and SET PARAMETER are used to write and read to SAP memory while IMPORT FROM MEMORY and EXPORT TO MEMORY are used for ABAP memory


Read more: Difference Between SAP memory and ABAP memory | Difference Between | SAP memory vs ABAP memory http://www.differencebetween.net/technology/software-technology/difference-between-sap-memory-and-abap-memory/#ixzz19ZPzN86a.

Saturday, December 4, 2010

Get-IP-address-all-computers-under-network

using System.Net;

string hostName = System.Net.Dns.GetHostName();

System.Net.IPHostEntry IpAddress = System.Net.Dns.GetHostEntry(hostName);

foreach(System.Net.IPAddress Ip in IpAddress.AddressList)
{
MessageBox.Show(Ip.ToString());
}   

Microsoft Certification terms.

 Microsoft Certified Professional (MCP),
Microsoft Certified IT Professional (MCITP),
Microsoft Certified Master(MCM),
Microsoft Certified architect (MCA)
Microsoft Certified Application Developer (MCAD),
Microsoft Certified Solution Developer (MCSD),
Microsoft Certified Technology Specialist (MCST),
Microsoft Certified Professional Developer (MCPD),
Microsoft Certified Systems Administrator (MCSA),
Microsoft Certified Database Administrator (MCDBA) ,
Microsoft Certified Desktop Support Technician(MCDST),
Microsoft Certified Application Specialist(MCAS)
Microsoft Certified Trainer(MCT),
Microsoft Certified Systems Engineer(MCSE),
Microsoft Office Specialist (MOS)

Thursday, December 2, 2010

Get System Processor Id for some validations

Firstly Make sure that you have added system.Management namespace and assembly.

public static string GetProcessorID()
{

string sProcessorID = "";

string sQuery = "SELECT ProcessorId FROM Win32_Processor";

ManagementObjectSearcher oManagementObjectSearcher = new ManagementObjectSearcher(sQuery);

ManagementObjectCollection oCollection = oManagementObjectSearcher.Get();
foreach (ManagementObject oManagementObject in oCollection)

{

sProcessorID = (string)oManagementObject["ProcessorId"];

}
return (sProcessorID);

}

Get list of Windows Services

ServiceController[] services = ServiceController.GetServices();

Sunday, November 28, 2010

Read SQl Server Name

using Microsoft.SqlServer.Management.Smo;

protected void Button1_Click(object sender, EventArgs e)
    {
        DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
        if (dt.Rows.Count > 0)
        {
            foreach (DataRow dr in dt.Rows)
            {
                Response.Write(dr["Name"].ToString() + "
");
            }
        }
    }
 
Note: You have to add a Reference of Microsoft.SqlServer.Smo dll. 

Unique Identifier for a computer

There are so many unique identifier. You may use Processor ID, any device Serial No. like Hard Drive Serial No. etc.

Please check the following code to read the ProcessorID:

public string GetMachineId()
    {
        string cpuInfo = String.Empty;
        ManagementClass managementClass = new ManagementClass("Win32_Processor");
        ManagementObjectCollection managementObjCol = managementClass.GetInstances();
        foreach (ManagementObject managementObj in managementObjCol)
        {
            if (cpuInfo == String.Empty)
            {
                cpuInfo = managementObj.Properties["ProcessorId"].Value.ToString();
            }
        }
        return cpuInfo;
    }


Note: You must add a reference of System.Management Assembly to use the above program.

Thursday, November 25, 2010

How to find the system is connected in LAN or not ?

 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
      
 
 
//Gets the machine names that are connected on LAN  
  
Process netUtility = new Process();  
  
netUtility.StartInfo.FileName = "net.exe";  
  
netUtility.StartInfo.CreateNoWindow = true;  
  
netUtility.StartInfo.Arguments = "view";  
  
netUtility.StartInfo.RedirectStandardOutput = true;  
  
netUtility.StartInfo.UseShellExecute = false;  
  
netUtility.StartInfo.RedirectStandardError = true;  
  
netUtility.Start();  
  
   
  
StreamReader streamReader = new StreamReader(netUtility.StandardOutput.BaseStream, netUtility.StandardOutput.CurrentEncoding);  
  
   
  
string line = "";  
  
while ((line = streamReader.ReadLine()) != null)  
  
{  
  
      if (line.StartsWith("\\"))  
  
      {  
  
           listBox1.Items.Add(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper());  
  
      }  
  
}  
  
streamReader.Close();  
netUtility.WaitForExit(1000);  


        }
    }
}

Thursday, October 21, 2010

To fetch out current date from internet instead of system.

Public void getdate()
{
            Random ran = new Random(DateTime.Now.Millisecond);
            DateTime date = DateTime.Today;
            string serverResponse = string.Empty;

            // Represents the list of NIST servers
            string[] servers = new string[] {
                         "64.90.182.55",
                         "206.246.118.250",
                         "207.200.81.113",
                         "128.138.188.172",
                         "64.113.32.5",
                         "64.147.116.229",
                         "64.125.78.85",
                         "128.138.188.172"
                          };

            // Try each server in random order to avoid blocked requests due to too frequent request
            for (int i = 0; i < 5; i++)
            {
                try
                {
                    // Open a StreamReader to a random time server
                    StreamReader reader = new StreamReader(new System.Net.Sockets.TcpClient(servers[ran.Next(0, servers.Length)], 13).GetStream());
                    serverResponse = reader.ReadToEnd();
                    reader.Close();

                    // Check to see that the signiture is there
                    if (serverResponse.Length > 47 && serverResponse.Substring(38, 9).Equals("UTC(NIST)"))
                    {
                        // Parse the date
                        int jd = int.Parse(serverResponse.Substring(1, 5));
                        int yr = int.Parse(serverResponse.Substring(7, 2));
                        int mo = int.Parse(serverResponse.Substring(10, 2));
                        int dy = int.Parse(serverResponse.Substring(13, 2));
                        int hr = int.Parse(serverResponse.Substring(16, 2));
                        int mm = int.Parse(serverResponse.Substring(19, 2));
                        int sc = int.Parse(serverResponse.Substring(22, 2));

                        if (jd > 51544)
                            yr += 2000;
                        else
                            yr += 1999;

                        date = new DateTime(yr, mo, dy, hr, mm, sc);

                        // Convert it to the current timezone if desired
                        //if (convertToLocalTime)
                            date = date.ToLocalTime();

                        // Exit the loop
                        break;
                    }

                }
                catch (Exception ex)
                {
                    /* Do Nothing...try the next server */
                }
            }

            textBox1.Text = date.ToString();
}

Saturday, September 18, 2010

Diffrences between Array and ArrayList.

1) The capacity of an Array is fixed. Where as, ArrayList can increase and decrease size dynamically.
2) An Array is a collection of similar items. Where as, ArrayList can hold item of different types.
3) Array is in the System namespace. Where as, ArrayList is in the System.Collections namespace.
4) An Array can have multiple dimensions. Where as, ArrayList always has exactly one dimension.
5) We can set the lower bound of an Array. Where as, The lower bound of an ArrayList is always zero.

Please check the following example:

ArrayList al = new ArrayList();
al.Add("1");
al.Add(2);
al.Add(new DateTime(2001, 4, 2));
foreach (object o in al)
{
Response.Write(o.ToString() + "
");
}

Friday, September 17, 2010

Remove Duplicate Records From a DataTable.

public DataTable DistinctRecordsFromDataTable(DataTable originalDT)
{
DataTable distinctDT = new DataTable();
DataView dv = originalDT.DefaultView;
System.Collections.Generic.List columns = new List();
//Add all the required columns which you want to get distinct to
//string list as follows
columns.Add("Column1");
columns.Add("Column2");
columns.Add("Column3");
columns.Add("Column4");
columns.Add("Column5");
distinctDT = dv.ToTable(true, columns.ToArray());
return distinctDT;
}

To Reset all of the controls of Form by one wrriting just one line.

you don't need to use loop or line by line of all controls to reset or clear them. You can just add the following code in your application:


Sunday, August 8, 2010

Fetch out More than 3 entries for one name and class column

Suppose you want to Fetch out More than 3 entries in a class with the same name of student, than you can use following query:
Here Id is table's primary key.

Select * from Table1 t6
where Id < (select MAX(Id) from (Select * from Table1 t4
where Id < (select max(Id) from (Select * from Table1 t2
where Id < (select Max(Id)from Table1 t1 where t1.name = t2.name and t1.class = t2.class)) t3 where t4.class= t3.class and t4.name = t3.name )) t5 where t6.class= t5.class and t6.name = t5.name )
order by t6.name desc



Thanks.

Generate Crystal Report from a Datatable and export it to HTML Report.

Select all data in a DataTable dt which you want to display in Report than make a form to display report FrmReportShow,put a CrystalReportViewer on it.
Insert a Crystal Report Report1 and a DataSet1 in your application and create a DataTable1 in Dataset1 and insert all columns that you want to display on report than set crystal report datasource to dataset1.


DataSet1 d = new DataSet1();
Report1 objRpt=new Report1();
foreach (DataRow dr in dt.Rows)
{
d.DataTable1.Rows.Add(dr.ItemArray);
}
FrmReportShow frs = new FrmReportShow();
ParameterField paramfield = new ParameterField();
ParameterFields paramfields = new ParameterFields();
ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
discreteval.Value = "Transferred";
paramfield.CurrentValues.Add(discreteval);
paramfields.Add(paramfield);
frs.crystalReportViewer1.ParameterFieldInfo = paramfields;
objRpt.SetDataSource(d);
frs.crystalReportViewer1.ReportSource = objRpt;
frs.crystalReportViewer1.Refresh();
objRpt.SetParameterValue("ReportType", "Not Transferred");

//Export Report to HTML

objRpt.ExportToDisk(ExportFormatType.HTML40, Application.StartupPath + "\\Report\\Report.html");
frs.Show();


-------------------------------
if have any query than ask.


Thanks.

A Term iFusion.net, What is this?

iFusion.net is some new term for our IT Field. This term is come from IBM i and Microsoft combination which provide facilities to organizations that now they can use IBM system with Microsoft applications which are built in .NET framework like SQL Server,Office etc.
This technology is the only one in IT industry in which two huge system combine into one.It is a complete solution with addressing presentation, business logic and database issues from a single platform.
By using fusion, the limitation of interoperability is near about remove which we occurred in many solutions like calling programs, replicating databases or transferring files – to create true composite applications that deliver real-time enterprise data and functionality to people as they need it.

Requirement/Importance of iFusion.net?

Many organizations use a combined IT environment that is difficult or complex to handle and constrains the responsiveness of the IT resources to changing business needs. All organizations need choice in how they build and deploy applications, but the choice is practical only when the IT resources can operate as a harmonized unit. iFusion.net gives solution by combining the IBM i and Windows platforms into a fused consolidated whole, where you build applications on the most appropriate platform or distribute across both. iFusion.net provide the things as follows :

* Gives appropriate faster action when responding to changing business needs.
* Accommodate choice for development options, preferences and available skills.
* Secure investment in the current assets – concern with people and applications.
* Mix the both of IBM i and Windows platforms.
* Build a flexible road map ranging from quick modernization to a full migration.
* Provide security and data integrity at every step.

Some Examples of iFusion.net :

There are much of important points between the IBM i system and Microsoft solutions:

* Fusing an e-commerce Web site which was built in ASP.NET to an IBM i ERP system, thereby publishing up-to-the-second inventory and pricing information along with straight-through order processing.
* Use or Fetch live operational data on the IBM i database (DB2) directly from a Windows or Web-based dashboard, without having any terminal session or toggle between multiple screens.
* Enhancing collaboration and work flow automation by combining tasks that use both Windows and IBM i functionality (including program logic, data queues and access to the IFS) inside a Microsoft Share Point enterprise portal with support for single sign-on.
* Provide all of Visual Studio.NET developers the authority to perform create, read, update and delete actions on the core databases — without risk of destroying data integrity or security.

For more details, visit http://www.ifusion.net/details.htm

Tuesday, August 3, 2010

How to Refresh a Web Page Automatically ??

There are Two way to refresh a web page


1. "."

2.This is the ASP.Net way
Response.AppendHeader("Refresh", "10; URL=http://www.dotnetspider.com")

ACRONYM HTML Tag

Ex: Get this ASAP

An acronym can be spoken as if it were a word, example NATO, NASA, ASAP, GUI.

By marking up acronyms you can give useful information to browsers, spellcheckers, screen readers, translation systems and search-engines.

To select nth row From a table

declare @num as int
set @num=3
select * from table1 a where @num=(select count(*) from table1 b where a.uid >= b.uid)

Monday, August 2, 2010

Use of Sql Exists Clause.

SQL: EXISTS Condition

The EXISTS condition is considered "to be met" if the subquery returns at least one row.

The syntax for the EXISTS condition is:

    SELECT columns
    FROM tables
    WHERE EXISTS ( subquery );

The EXISTS condition can be used in any valid SQL statement - select, insert, update, or delete.

Example #1

Let's take a look at a simple example. The following is an SQL statement that uses the EXISTS condition:

    SELECT *
    FROM suppliers
    WHERE EXISTS
      (select *
        from orders
        where suppliers.supplier_id = orders.supplier_id);

This select statement will return all records from the suppliers table where there is at least one record in the orders table with the same supplier_id.

DIFFRENCE BETWEEN GARBAGE COLLECTION AND DISPOSE METHOD.

(*) Garbage Collection is the .NET Framework way of freeing and releasing the memory occupied by managed objects of the .Net Object Oriented Programming model. The Garbage Collection is called by runtime to free memory used by "managed" resources.

(*) IDisposable.Dispose() method is also meant for same action of freeing resources. But in additon, you can make its best use to free "unmanaged" resources.

Now, what are the unmanaged resources. Unmanaged resources are such as Files, NetWork, Streams and COM types. So in this case these resources unnecessarily unknowingly consume much resources & GC also not helps.

Use of SqlBulkCopy Function to insert row in Bulk in table.

System.Data.DataTable table = dt;
SqlConnection cn = new SqlConnection(dbc.Constr.ToString());  
SqlBulkCopy cc = new SqlBulkCopy(cn);
cc.DestinationTableName = "dbo.Temp_Report";
cn.Open();
cc.WriteToServer(table);
cn.Close();

Monday, June 14, 2010

Checking net connection in your system in C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.NetworkInformation;

namespace demoConnection
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}

private void timer1_Tick(object sender, EventArgs e)
{
bool test = IsConnectedToInternet();
if (test == true)
{
label1.Text = " Connected";
}
else
{
label1.Text = "Not Connected";
}
}

private bool IsConnectedToInternet()
{
string host = "http://www.c-sharpcorner.com";
bool result = false;
Ping p = new Ping();
try
{
PingReply reply = p.Send(host, 3000);
if (reply.Status == IPStatus.Success)
return true;
}
catch { }
return result;
}
}
}

Monday, May 31, 2010

Make connection with .dbf file and read and write with C# .

There are two way to make connection with .dbf file :

1. With ODBC Connection.

           string filepath = "c:\\nn\\";
           
           OdbcConnection CC = new OdbcConnection("Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB=" + filepath + ";Exclusive=No; Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;");
            CC.Open();
           
            OdbcCommand cmd = new OdbcCommand("Select * From " + filepath + "smsout.dbf" , CC);
            OdbcDataReader dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                DataTable dt = new DataTable();
                dt.Load(dr);
            }
            CC.Close();

2. With OLEDB Connection.

            OleDbConnection ccc = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath.Substring(0, filepath.LastIndexOf("\\")) + ";Extended Properties=dBASE IV;");
            ccc.Open();
            OleDbCommand cmd1 = new OleDbCommand("Select * From " + filepath + "smsout.dbf", ccc);
            OleDbDataReader dr1 = cmd1.ExecuteReader();
            if (dr1.HasRows)
            {
                DataTable dt1 = new DataTable();
                dt1.Load(dr1);
            }
            ccc.Close();

Wednesday, May 19, 2010

What is Decode sql functions ?

Decode is the sql functions for the replacement of If- Then -else logic and case is similar to
If-Then-else logic except that we can make logical comparison of columns involved in the case
structures.
Ex: select case snum when snum > 10 then 'High' when snum>5 then 'Low' end from sales.

Ex: select decode(snum,10,'high',5,'low') from sales... that is we cannot make logical comparison of columns in Decode() functions.

Ex: SELECT NAME,SAL,DECODE(DEPTNO,10,'ACCOUNTING',20,'RESEARCH',30,'SALES',40,'OPERATIONS','OTHERS')
"DEPARTMENTS" FROM EMP;

A DECODE FUNCTION ALWAYS TAKES MINIMUM OF 4 ARGUMENTS
DECODE
IF N1=N2
THEN RETURN N3
ELSE
RETURN N4

Diffrence between SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY

SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY are similar functions in that they return values inserted into IDENTITY columns.

IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the value generated for a specific table in any session and any scope.

SCOPE_IDENTITY and @@IDENTITY will return last identity values generated in any table in the current session. However, SCOPE_IDENTITY returns values inserted only within the current scope; @@IDENTITY is not limited to a specific scope.

For example, you have two tables, T1 and T2, and an INSERT trigger defined on T1. When a row is inserted to T1, the trigger fires and inserts a row in T2. This scenario illustrates two scopes: the insert on T1, and the insert on T2 as a result of the trigger.

Assuming that both T1 and T2 have IDENTITY columns, @@IDENTITY and SCOPE_IDENTITY will return different values at the end of an INSERT statement on T1.
@@IDENTITY will return the last IDENTITY column value inserted across any scope in the current session, which is the value inserted in T2.
SCOPE_IDENTITY() will return the IDENTITY value inserted in T1, which was the last INSERT that occurred in the same scope. The SCOPE_IDENTITY() function will return the NULL value if the function is invoked before any insert statements into an identity column occur in the scope.

What is the difference between #include and #include ?file?? or "file"

We have two ways to include files in a project.

The first way is to include with the angled brackets <>. This method of inclusion tells the compiler to look for the file in the predefined default location. This predefined default location is often an INCLUDE environment variable that denotes the path to your include files. For instance, given the INCLUDE variable
INCLUDE=C:COMPILERINCLUDE;S:SOURCEHEADERS;

If the file is not found there, the compiler then checks the S:SOURCEHEADERS directory. If the file is still not found, the compiler checks the current directory.

The second way to include files is include with double quotation marks. This method of inclusion tells the compiler to look for the file in the current directory first, then look for it in the predefined locations you have set up. Using the #include ?file? version of file inclusion and applying it to the preceding example, the compiler first checks the current directory for the
specified file. If the file is not found in the current directory, the C:COMPILERINCLUDE directory is searched. If the file is still not found, the compiler checks the S:SOURCEHEADERS directory.

The #include method of file inclusion is often used to include standard headers such as stdio.h or stdlib.h. This is because these headers are rarely (if ever) modified, and they should always be read from your compiler?s standard include file directory.

The #include ?file? method of file inclusion is often used to include nonstandard header files that you have created for use in your program. This is because these headers are often modified in the current directory, and you will want the compiler to use your newly modified version of the header rather than the older, unmodified version.

#include
This will refer the given file in the standard input and output directory.
but
#include"file"
This will first refers the given file in the current directory if this not found it will refers in the standard input and output directory.

Tuesday, May 4, 2010

Three way to get the name of month from a Date.

1. string str= String.Format("{0:mmmm}", DateTime.Now);

2. string str = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month);

3. System.Globalization.DateTimeFormatInfo ifo = new
System.Globalization.DateTimeFormatInfo();
str = ifo.GetMonthName(Date.Month);

By following the same way you can also get the name of the year or day of from date.

Thanks.

Thursday, April 29, 2010

Diffrence Between MFC and ATL projects

Microsoft Foundation Classes (MFC)
The C++ class library that Microsoft provides with its C++ compiler to assist programmers in creating Windows-based applications. MFC hides the fundamental Windows API in class hierarchies so that programmers can write a Windows-based application without needing to know the details of the native Windows API.
Microsoft created MFC to make the development of applications for Windows much easier than it was using the SDK.

Active Template Library (ATL)
A C++ template library used to create ActiveX servers and other Component Object Model (COM) objects. ActiveX controls created with ATL are generally smaller and faster than those created with the Microsoft Foundation Classes.
ATL provides a framework to implement the code necessary to create
COM clients and servers. The two frameworks overlap in their usefulness for
developing ActiveX controls.
ATL's purpose in is to save developers from having to rewrite IUnknown,
IDispatch, IClassFactory, and all the hooks for turning regular DLLs and EXEs into
COM-based DLLs and EXEs. In this respect, ATL is a much lighter framework than MFC,
and ATL was designed and built with COM support in mind.

The differences between the two architectures are fairly stark. Generally, MFC enables you to get your project up and running more quickly, but sacrifices flexibility. ATL isn't quite as quick and easy to use, but it is COM-friendly. In addition, ATL appears to be getting easier to use as it matures.

Thanks.

About Active X and COM

ActiveX
A set of technologies that enable software components to interact with one another in a networked environment, regardless of the language in which the components were created. ActiveX, which was developed as a proposed standard by Microsoft in the mid 1990s and is currently administered by the Open Group, is built on Microsoft's Component Object Model (COM). Currently, ActiveX is used primarily to develop interactive content for the World Wide Web, although it can be used in desktop applications and other applications. ActiveX controls can be embedded in Web pages to produce animation and other multimedia effects, interactive objects, and sophisticated applications. See also COM.

ActiveX client
An application or tool that calls an ActiveX object.

ActiveX object
An exposed object of the Component Object Model (COM).

Component Object Model (COM)
An open architecture for cross-platform development of client/server applications. It is based on object-oriented technology as agreed upon by Digital Equipment Corporation and Microsoft Corporation. COM defines the interface, similar to an abstract base class, IUnknown, from which all COM-compatible classes are derived.

Thanks.

Diffrence between Strcpy(), Strncpy() and strcpy_s() Functions

Consider the code snippet:

char str[5];
strcpy (str, "Hello");

This will copy the word “Hello” to the character buffer ‘str’, but if i write ,

strcpy (str, "Hello world");

it will corrupt the memory in adjacent locations to str because the buffer str is only 5 bytes long and the source string is

11 bytes. The safe way is use the strncpy() function that takes the size of the destination buffer also as an argument.

strncpy (str, "Hello", 5);

or

strncpy (str, "Hello world",5);

Now, irrespective of the size of the source string, only 5 bytes will be copied to str.

Taking one step ahead, Microsoft released a set of more secure versions of these functions in Visual C++ 2005. This enhanced

set includes secure versions of functions like strcpy, ctime, fopen, scanf and many more.

The newer functions have the same function name appended by the “_s” suffix. e.g. the secure version for strcpy() is

strcpy_s(). Of course, there are differences in function prototypes. In the case of strcpy() and strcpy_s() they are:

char *strcpy( char *strDest, const char *strSrc );
errno_t strcpy_s( char *strDest, size_t nSize, const char *strSrc );

You will notice that strcpy_s() takes size of the destination buffer also, as an input parameter.

Thursday, April 22, 2010

New Visual Studio 2010 and .NET Framework 4.0

After a very long changes, Visual Studio is available within its development interface, which now uses WPF(Windows Presentation Foundation). In this new VS the IDE of new VS now supports the use of multiple monitors, that means code can appear in more than one monitor like one monitor use code while another is used to display the database structure or etc. It also provide the all known look of "ribbon" interface that first came in Office 2007.

The Programmer or Developers will be happy with the new toolbox that can be used to target multiple platforms, ranging from standard binaries, to developing Silverlight apps.

It also provides a platform with which developers can build apps for Windows Phone 7.

New ASP.NET features
* Static IDs for ASP.NET Controls
* The Chart control
* Web.config transformation

New VB.NET features
* Auto Implemented Properties for VB.NET
* Collection Initializers
* Implicit Line Continuations
* Statements in Lambda Expressions

New C# features
* Dynamic Types
* Optional parameters
* Named and Optional Arguments

-------------------------------------------------------
posted by:Anil Jain

Thursday, April 8, 2010

How to show OpenFileDialogBox in VC++

CFileDialog *CommDlg;
char Filetype[] = "All Files (*.EXE)|*.EXE||";
CommDlg = new CFileDialog(TRUE, NULL, NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,Filetype,this);
CommDlg->DoModal();

UpdateData(TRUE);
CString Filename;
CString m_AppPath = CommDlg->GetPathName();
if(m_AppPath.IsEmpty())
{
delete CommDlg;
return;
}
Filename = CommDlg->GetFileName();
int Filesize = Filename.GetLength();

Wednesday, February 3, 2010

How to make elipse or circle in win application in C#.net

//posted by anil jain

hi dear,
To draw a circle or elipse in win application u have to use VisualBasicPowerPacks controls. you can add them by add reference of VisualBasicPowerPacks,if you are not getting them there then install VisualBasicPowerPacks by VisualBasicPowerPackssetup.exe and then add reference of VisualBasicPowerPacks.

Enjoy!

@nil!

Tuesday, February 2, 2010

How to use java script in win application in C#.net

//posted by anil jain

using System.CodeDom;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.JScript;

CodeDomProvider p;
CompilerParameters cp;
CompilerResults cr;
Assembly asmbly;
Type Type;
object Obj;
string javascript = //suppose I have a API for label1.
@"class a
{
var label1='Hi dear';
}";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
p = (CodeDomProvider)Activator.CreateInstance("Microsoft.JScript", "Microsoft.JScript.").Unwrap();
}

private void button1_Click(object sender, EventArgs e)
{
this.para = new CompilerParameters();
this.cp.GenerateInMemory = true;
this.cr = provider.CompileAssemblyFromSource(this.cp, javascript);
this.asmbly = cr.CompiledAssembly;
this.Type = assembly.GetType("a");
this.Obj = Activator.CreateInstance(this.Type);
object retValue = this.Type.InvokeMember("label1", BindingFlags.GetField, null, this.Obj, null);
label1.Text = retValue.ToString();
}

How to send mail in C#.net

//posted by anil jain

//in web.config








//in cs

using System.Net.Mail;

MailMessage Mail = new MailMessage("mailaddressfrom@smartit.com", "mailaddressto@smartit.com");
Mail.Subject = TextBox2.Text;
Mail.IsBodyHtml = true;
Mail.Body = FCKeditor1.Value;
Mail.Priority = MailPriority.High;
for (int i = 0; i < a.Count; i++)
{
Mail.Bcc.Add(a[i].ToString());
}
SmtpClient smtp = new SmtpClient();
smtp.Send(Mail);

How to Create Trigger in sql

//posted by anil jain

CREATE TRIGGER trig1 ON trig_example FOR INSERT
as
IF (SELECT COUNT(*) FROM INSERTED
WHERE salary > 100000) > 0
BEGIN
print "TRIG1 Error: you attempted to insert a salary > $100,000"
ROLLBACK TRANSACTION
END


CREATE trigger Tg_Update_directory_date on directory
for insert
as

insert into directory_update (directory_id,update_date)
select max(directory_id) as directory_id, getdate() from directory)


CREATE TRIGGER tr_Orders_INSERT
ON Orders
FOR INSERT
AS
IF (SELECT COUNT(*) FROM inserted WHERE Ord_Priority = 'High') = 1
BEGIN
PRINT 'Email Code Goes Here'
END

get all drives letter of your harddisk in win application in C#.net

string[] sDriveLetter = Environment.GetLogicalDrives();

get the root directory in win application in C#.net

string root = Environment.SystemDirectory.ToString().Substring(0, 1);

get the application root path in Win Application in C#.net

string destpath = System.IO.Directory.GetParent(System.Windows.Forms.Application.ExecutablePath).Parent.Parent.FullName + "\\pic\\" + openFileDialog1.SafeFileName.ToString();

Delete Spool of Printer in windows XP

//Posted by anil jain

string[] Files = Directory.GetFiles(root + ":\\WINDOWS\\System32\\spool\\PRINTERS\\", "*", SearchOption.AllDirectories);
for (int i = 0; i < Files.Count(); i++)
{
try
{
File.Delete(Files.ElementAt(i));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Last Logged User History in windows XP

//posted by anil jain

RegistryKey Rkey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Winlogon", true);
if (Rkey != null)
{
Registry.CurrentUser.DeleteSubKeyTree("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Winlogon\\");
}

Clear Run list in windows XP

//posted by anil jain

RegistryKey Rkey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU", true);
if (Rkey != null)
{
Registry.CurrentUser.DeleteSubKeyTree("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU\\");
}

Tray Notification in windows XP

//Posted by anil jain

RegistryKey Rkey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\TrayNotify", true);
if (Rkey != null)
{
Registry.CurrentUser.DeleteSubKeyTree("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\TrayNotify\\");
}

MenuOrder Cache in windows XP

//posted by anil jain


RegistryKey Rkey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MenuOrder", true);
if (Rkey != null)
{
Registry.CurrentUser.DeleteSubKeyTree("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MenuOrder\\");
}

get data from Windows Log Files in windows XP

//posted by anil jain

//Windows Log Files-->C:\WINDOWS\System32\config or C:\WINDOWS\System32\winevt\Logs

if (Directory.Exists("C:\\WINDOWS\\System32\\config\\"))
{
string[] Files = Directory.GetFiles(root + ":\\WINDOWS\\System32\\config\\", "*", SearchOption.AllDirectories);
for (int i = 0; i < Files.Count(); i++)
{
try
{
File.Delete(Files.ElementAt(i));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

if (Directory.Exists("C:\\WINDOWS\\System32\\winevt\\Logs\\"))
{
string[] Files1 = Directory.GetFiles(root + ":\\WINDOWS\\System32\\winevt\\Logs\\", "*", SearchOption.AllDirectories);
for (int i = 0; i < Files1.Count(); i++)
{
try
{
File.Delete(Files1.ElementAt(i));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

ChkDsk File Fragments in windows XP

//Posted By anil jain

string[] Files=Directory.GetFiles(root + ":\\Program Files\\","*.chk",SearchOption.AllDirectories);
for (int i = 0; i < Files.Count(); i++)
{
try
{
File.Delete(Files.ElementAt(i));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
string[] Files1 = Directory.GetFiles(root + ":\\Windows\\", "*.chk", SearchOption.AllDirectories);
for (int i = 0; i < Files1.Count(); i++)
{
try
{
File.Delete(Files1.ElementAt(i));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Delete Memory Dumps in windows XP

//Posted by anil jain

//Memory Dumps -->3-types => Complete,small(mini),Kernal

string memorydump= root + ":\\WINDOWS\\Minidump";
string[] a= Directory.GetFiles(memorydump);
for (int i = 0; i < a.Count(); i++)
{
try
{
File.Delete(a.ElementAt(i));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

if (File.Exists(root + ":\\WINDOWS\\MEMORY.DMP"))
{
File.Delete(root + ":\\WINDOWS\\MEMORY.DMP");
}

Get Recycle bin data from Windows 7 in C#.Net

//Posted by anil jain

if (sOsVersion.IndexOf("6.1.7") > 0) //Windows 7
{
for (int j = 0; j < sDriveLetter.Count(); j++)
{
string[] Files1 = Directory.GetFiles(sDriveLetter.ElementAt(j) + "$Recycle.Bin\\", "*", SearchOption.AllDirectories);
for (int i = 0; i < Files1.Count(); i++)
{
//File.Delete(Files1.ElementAt(i));
myList.Add(Files1.ElementAt(i));
}
}
}

Get or Fetch and delete data from recyclebin in windows XP

//posted by anil jain

List myList = new List();

string sOsVersion = System.Environment.OSVersion.ToString();
Environment.GetEnvironmentVariable("windir", EnvironmentVariableTarget.Machine);
string[] sDriveLetter = Environment.GetLogicalDrives();

if (sOsVersion.IndexOf("5.1.2") > 0) //For Windows XP
{
for (int j = 0; j < sDriveLetter.Count(); j++)
{
try
{
string[] Files = Directory.GetFiles(sDriveLetter.ElementAt(j) + "Recycler\\", "*", SearchOption.AllDirectories);

for (int i = 0; i < Files.Count(); i++)
{
try
{
//File.Delete(Files.ElementAt(i));
myList.Add(Files.ElementAt(i));
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

Monday, February 1, 2010

Success is = Luck but if you want it then Make it your Choice

I find and also i think that maximum people(including me) relate success with luck.

That brings me to discuss about SUCCESS, or may I say: Success Ability= your ability to Success.

One part of the Success is your personal attitude,behavior & circumstances , such as: my age, my financial situation, my education, my parents, my kids, I'm too tall, I'm too short, I'm too fat etc.

The other part of the circumstances is external circumstances, such as: the economic situation, the currency rate, the whether, the neighborhood I was raised etc.

The personal circumstances and the external circumstances, they are both just circumstances.
There 2 ways the human being acts upon the circumstances. One way, is by the question: "How the circumstances affect on me"? That is the way of the VICTIM, the victim of the circumstances.

The other way is by the sentence: "Okay, this is me, this is my age, this is my financial situation, this is my education, and these are my parents and within all that:

1. Where do I want to go, what are my goals and dreams in life?

2. What's do I need to do to reach those goals and dreams?"

That is the way of the MASTER.

The VICTIM and the MASTER are within each and every one of us. They are always in conflict.

Now you create a distinction, so by listening to your own words, you can easily recognize whether it's the MASTER or the VICTIM who is talking out of your mouth. If you are not sure what do in some situations, ask yourself what a MASTER would do in this case.

I encourage you not to let the VICTIM to win in the game of life and always be in a MASTER mindset.

Love you All,

Anil Jain(**@nil**)