1. Slide hướng dẫn/ contractor slide
Tạo Crystal Report dùng Store Procedure
2. Source code: download
^(From|To|Subject|Date):
^(From|To|Subject|Date):
using System;
using System.Net;
namespace GetIPCS
{
///
/// Gets IP addresses of the local machine
///
class classGetIPCS
{
///
/// Gets IP addresses of the local machine
///
[STAThread]
static void Main(string[] args)
{
// Get host name
String strHostName = Dns.GetHostName();
Console.WriteLine("Host Name: " + strHostName);
// Find host by name
IPHostEntry iphostentry = Dns.GetHostByName(strHostName);
// Enumerate IP addresses
int nIP = 0;
foreach(IPAddress ipaddress in iphostentry.AddressList)
{
Console.WriteLine("IP #" + ++nIP + ": " +
ipaddress.ToString());
}
}
}
}
2. Delphi
uses Winsock; function getIPs: Tstrings; type TaPInAddr = array[0..10] of PInAddr; PaPInAddr = ^TaPInAddr; var phe: PHostEnt; pptr: PaPInAddr; Buffer: array[0..63] of Char; I: Integer; GInitData: TWSAData; begin WSAStartup($101, GInitData); Result := TstringList.Create; Result.Clear; GetHostName(Buffer, SizeOf(Buffer)); phe := GetHostByName(buffer); if phe = nil then Exit; pPtr := PaPInAddr(phe^.h_addr_list); I := 0; while pPtr^[I] <> nil do begin Result.Add(inet_ntoa(pptr^[I]^)); Inc(I); end; WSACleanup; end; procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(GetIps.text); end;
Private Sub IPAddress() 'To get local address Dim LocalHostName As String Dim i As Integer LocalHostName = Dns.GetHostName() Dim ipEnter As IPHostEntry = Dns.GetHostByName(LocalHostName) Dim IpAdd() As IPAddress = ipEnter.AddressList For i = 0 To IpAdd.GetUpperBound(0) Next End Sub4. C
// Borland C++ 5.0: bcc32.cpp getlocalip.cpp // Visual C++ 5.0: cl getlocalip.cpp wsock32.lib // // This sample program is hereby placed in the public domain. #include #include int doit(int, char **) { char ac[80]; if (gethostname(ac, sizeof(ac)) == SOCKET_ERROR) { cerr < < "Error " << WSAGetLastError() << " when getting local host name." << endl; return 1; } cout << "Host name is " << ac << "." << endl; struct hostent *phe = gethostbyname(ac); if (phe == 0) { cerr << "Yow! Bad host lookup." << endl; return 1; } for (int i = 0; phe->h_addr_list[i] != 0; ++i) { struct in_addr addr; memcpy(&addr, phe->h_addr_list[i], sizeof(struct in_addr)); cout < < "Address " << i << ": " << inet_ntoa(addr) << endl; } return 0; } int main(int argc, char *argv[]) { WSAData wsaData; if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) { return 255; } int retval = doit(argc, argv); WSACleanup(); return retval; } }
import java.net.*; import java.io.*; public class GetIPAddress { public static void main(String [] args) { try { InetAddress thisIp =InetAddress.getLocalHost(); System.out.println("IP:"+thisIp.getHostAddress()); } catch(Exception e) { e.printStackTrace(); } } }
8. PHPstring ip; ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR"); if(ip==string.Empty) { ip=Request.ServerVariables("REMOTE_ADDR"); }
PHP Code:
$ip=$_SERVER['REMOTE_ADDR'];
<% Response.Write Request.ServerVariables("REMOTE_ADDR") %>
namespace Test{public delegate int Calculation(int a, int b);class Program{static int Add(int a, int b){return a + b;}static void Main(string[] args){Calculation ca = new Calculation(Add);int c = ca(5, 4);Console.WriteLine(“c = {0}”, c);Console.ReadLine();}}}
using System; namespace Test {public delegate int Calculation(int a, int b); class Program {static int Add(int a, int b) {return a + b;} static int Sub(int a, int b) {return a – b;}static int Calculate(int a, int b, Calculation cal) {return cal(a, b);} static void Main(string[] args) {int c = Calculate(5, 4, Add); Console.WriteLine(“c = {0}”, c); int d = Calculate(5, 4, Sub); Console.WriteLine(“d = {0}”, d); Console.ReadLine();}}}
class Customer {private string name;public string Name {get {return this.name;} set{this.name = value;}}}
class TimeUtil {public DateTime CurrentTime{get {return DateTime.Now;}}}
class Customer {public string Name {get;set;}}
public delegate void ErrorNotification(string message);class MyMachine{public event ErrorNotification Notify;public void ReportError(string error) {if (Notify != null)Notify(error);}}
static void Main(string[] args) {MyMachine machine = new MyMachine();machine.Notify += new ErrorNotification(PrintString);machine.ReportError(“Some bug ocurred”);Console.ReadLine();}static void PrintString(string msg){Console.WriteLine(msg);}
class MyMachine{private ErrorNotification notify;//Delegate instance//Event declarationpublic event ErrorNotification Notify{add{this.notify += value;}remove{this.notify -= value;}}public void ReportError(string error) {if (notify != null)notify(error);}}
static void Main(string[] args) {MyMachine machine = new MyMachine();machine.Notify += new ErrorNotification(PrintString);machine.ReportError(“Some bug ocurred”);Console.ReadLine();}static void PrintString(string msg){Console.WriteLine(msg);}
public event EventHandler MyEvent