bcoder

PHP字符串函数

 分类:PHP 阅读 (1,977)  No Responses »
10月 272012
 

AddSlashes: 字符串加入斜线。
bin2hex: 二进位转成十六进位。
Chop: 去除连续空白。

chr: 语法:chr(ascii); 功能:返回序ascii码值对应的字符。
ascii: ascii码值。
注意:ascii 参数可以是十进制、八进制或十六进制。通过前置 0 来规定八进制,通过前置 0x 来规定十六进制。

chunk_split: 将字符串分成小段。
convert_cyr_string: 转换古斯拉夫字符串成其它字符串。
crypt: 将字符串用 DES 编码加密。
echo: 输出字符串。

explode 语法:explode(seperator,string,limit);功能:切开字符串成数组。
seperator: 代表要分隔标记的字符串,必要参数。
string:要进行分割的字符串,必要参数。
limit:可返回的最多的数组值数量。
返回值:如果成功返回以seperator分隔的字符串数组,失败返回false
其他说明:seperator不能为空,如果此参数为空则返回false
如果limit小于可能的分隔字符串个数,则只返回limit个数组项,最后多余的字符串将加到最一个数组项中。

flush: 清出输出缓冲区。
get_meta_tags: 抽出文件所有 meta 标记的资料。
htmlspecialchars: 将特殊字符转成 HTML 格式。
htmlentities: 将所有的字符都转成 HTML 字符串。
implode: 将数组变成字符串。
join: 将数组变成字符串。
ltrim: 去除连续空白。
md5: 计算字符串的 MD5 哈稀。
nl2br: 将换行字符转成 <br>。
Ord: 返回字符的序数值。
parse_str: 解析 query 字符串成变量。
print: 输出字符串。
printf: 输出格式化字符串。
quoted_printable_decode: 将 qp 编码字符串转成 8 位字符串。
QuoteMeta: 加入引用符号。
rawurldecode: 从 URL 专用格式字符串还原成普通字符串。
rawurlencode: 将字符串编码成 URL 专用格式。
setlocale: 配置地域化信息。
similar_text: 计算字符串相似度。
soundex: 计算字符串的读音值
sprintf: 将字符串格式化。
strchr: 寻找第一个出现的字符。
strcmp: 字符串比较。
strcspn: 不同字符串的长度。
strip_tags: 去掉 HTML 及 PHP 的标记。
StripSlashes: 去掉反斜线字符。
strlen: 取得字符串长度。
strrpos: 寻找字符串中某字符最后出现处。

strpos  语法:strpos(string,find,start); 功能:寻找字符串中某字符最先出现处。
string:被搜索的字符串,必要参数
find:要查找的字符串,必要参数
start:查找字符串的起始位置,可选参数。
返回值:如果查找到字符串返回子字符串在源字符串中的位置,以0开始,否则返回false或者null?
其他说明:此函数对大小写敏感,如果处理对大小不敏感的字符串请使用stripos.
用例1:if (strpos($hkey, “chk”) != null) { echo “ok”;}
用例2:echo (“bcoder.com”, “bcoder”); //结果为0

strrchr: 取得某字符最后出现处起的字符串。
strrev: 颠倒字符串。
strspn: 找出某字符串落在另一字符串遮罩的数目。
strstr: 返回字符串中某字符串开始处至结束的字符串。
strtok: 切开字符串。
strtolower: 字符串全转为小写。
strtoupper: 字符串全转为大写。

str_replace  语法 :str_replace(find,replace,string,count);功能:字符串替换。
find:要查找的字符串,必要参数
replace:要替换为的字符串,必要参数
string:被搜索的字符串,必要参数
count:记录替换的字符串的个数,可选参数
返回值:返回被替换后的字符串

strtr: 转换某些字符。

substr  语法:string substr ( string , start [, length ] )。功能: 取部份字符串。
string: 传入的字符串,要取子串的字符串
start: 从哪个位置开始取,如此参数为非负数,则从start位置开始取,第一个字符位置为0,如“abcdef”中a的位置为0;如果start为负数,则函数从字符结尾往前开始数;如果start大于或者等于字符串的长度,则函数返回false
length: 如果为正数,从start位置往后取,直到字符串的结尾;如果为负数……;如果为0, false或者null返回空字符串;如果没提供此参数,则从start位置下取到字符串结尾。

 

trim: 截去字符串首尾的空格。
ucfirst: 将字符串第一个字符改大写。
ucwords: 将字符串每个字第一个字母改大写

PHP中输出换行符的方法

 分类:PHP 阅读 (3,744)  No Responses »
10月 272012
 

在PHP中输出换行符的方法,是指生成的html代码里有换行符,不是生成<br>那种

在windows中输入rn
echo “rn”;

在Linux中输出n即可
echo “n”;

注意:必须用双引号括住两边

Html特殊字符编码表

 分类:Other 阅读 (2,396)  No Responses »
10月 262012
 
1. HTML码都以&开始并以;结尾
2. 记住一些字符的英语全拼可以方便记住这些符号,比如:< lt 为less than, > gt 为greater than, 空格 nbsp为Non-breaking Space
字符 HTML码 十进制码 字符 HTML码 十进制码 字符 HTML码 十进制码
Α &Alpha; &#913; Β &Beta; &#914; Γ &Gamma; &#915;
Δ &Delta; &#916; Ε &Epsilon; &#917; Ζ &Zeta; &#918;
Η &Eta; &#919; Θ &Theta; &#920; Ι &Iota; &#921;
Κ &Kappa; &#922; Λ &Lambda; &#923; Μ &Mu; &#924;
Ν &Nu; &#925; Ξ &Xi; &#926; Ο &Omicron; &#927;
Π &Pi; &#928; Ρ &Rho; &#929; Σ &Sigma; &#931;
Τ &Tau; &#932; Υ &Upsilon; &#933; Φ &Phi; &#934;
Χ &Chi; &#935; Ψ &Psi; &#936; Ω &Omega; &#937;
α &alpha; &#945; β &beta; &#946; γ &gamma; &#947;
δ &delta; &#948; ε &epsilon; &#949; ζ &zeta; &#950;
η &eta; &#951; θ &theta; &#952; ι &iota; &#953;
κ &kappa; &#954; λ &lambda; &#955; μ &mu; &#956;
ν &nu; &#957; ξ &xi; &#958; ο &omicron; &#959;
π &pi; &#960; ρ &rho; &#961; ? &sigmaf; &#962;
σ &sigma; &#963; τ &tau; &#964; υ &upsilon; &#965;
φ &phi; &#966; χ &chi; &#967; ψ &psi; &#968;
ω &omega; &#969; ϑ &thetasym; &#977; ϒ &upsih; &#978;
ϖ &piv; &#982; &bull; &#8226; &hellip; &#8230;
&prime; &#8242; &Prime; &#8243; &oline; &#8254;
&frasl; &#8260; &weierp; &#8472; &image; &#8465;
&real; &#8476; &trade; &#8482; &alefsym; &#8501;
&larr; &#8592; &uarr; &#8593; &rarr; &#8594;
&darr; &#8595; &harr; &#8596; &crarr; &#8629;
&lArr; &#8656; &uArr; &#8657; &rArr; &#8658;
&dArr; &#8659; &hArr; &#8660; &forall; &#8704;
&part; &#8706; &exist; &#8707; &empty; &#8709;
&nabla; &#8711; &isin; &#8712; &notin; &#8713;
&ni; &#8715; &prod; &#8719; &sum; &#8722;
&minus; &#8722; &lowast; &#8727; &radic; &#8730;
&prop; &#8733; &infin; &#8734; &ang; &#8736;
&and; &#8869; &or; &#8870; &cap; &#8745;
&cup; &#8746; &int; &#8747; &there4; &#8756;
&sim; &#8764; &cong; &#8773; &asymp; &#8773;
&ne; &#8800; &equiv; &#8801; &le; &#8804;
&ge; &#8805; &sub; &#8834; &sup; &#8835;
&nsub; &#8836; &sube; &#8838; &supe; &#8839;
&oplus; &#8853; &otimes; &#8855; &perp; &#8869;
&sdot; &#8901; &lceil; &#8968; &rceil; &#8969;
&lfloor; &#8970; &rfloor; &#8971; &loz; &#9674;
&spades; &#9824; &clubs; &#9827; &hearts; &#9829;
&diams; &#9830; &nbsp; &#160; ¡ &iexcl; &#161;
&cent; &#162; &pound; &#163; ¤ &curren; &#164;
&yen; &#165; | &brvbar; &#166; § &sect; &#167;
¨ &uml; &#168; © &copy; &#169; a &ordf; &#170;
« &laquo; &#171; ¬ &not; &#172; &shy; &#173;
® &reg; &#174; ˉ &macr; &#175; ° &deg; &#176;
± &plusmn; &#177; 2 &sup2; &#178; 3 &sup3; &#179;
&acute; &#180; μ &micro; &#181 &quot; &#34;
< &lt; &#60; > &gt; &#62; &#39;
& &amp;
10月 242012
 

  当用户在安装程序时选择了相应的语言后,我们希望我们的程序中的相应的语言选项也变相同的设置,这样避免用户在进入程序后再一次选择语言设置。
  在此我们用到了$Language变量,读取该变量的值,并根据此值将相应的配置写到ini或者注册表中。
  我们将在onInstSuccess中实现该功能.
  代码如下:

附链接:各语言在Windows中的代码值

 

10月 242012
 
Locale ▾ Language
code
LCID
string
LCID
Decimal
LCID
Hexadecimal
Codepage
Afrikaans af af 1078 436 1252
Albanian sq sq 1052 1250
Amharic am am 1118
Arabic – Algeria ar ar-dz 5121 1401 1256
Arabic – Bahrain ar ar-bh 15361 1256
Arabic – Egypt ar ar-eg 3073 1256
Arabic – Iraq ar ar-iq 2049 801 1256
Arabic – Jordan ar ar-jo 11265 1256
Arabic – Kuwait ar ar-kw 13313 3401 1256
Arabic – Lebanon ar ar-lb 12289 3001 1256
Arabic – Libya ar ar-ly 4097 1001 1256
Arabic – Morocco ar ar-ma 6145 1801 1256
Arabic – Oman ar ar-om 8193 2001 1256
Arabic – Qatar ar ar-qa 16385 4001 1256
Arabic – Saudi Arabia ar ar-sa 1025 401 1256
Arabic – Syria ar ar-sy 10241 2801 1256
Arabic – Tunisia ar ar-tn 7169 1256
Arabic – United Arab Emirates ar ar-ae 14337 3801 1256
Arabic – Yemen ar ar-ye 9217 2401 1256
Armenian hy hy 1067
Assamese as as 1101
Azeri – Cyrillic az az-az 2092 1251
Azeri – Latin az az-az 1068 1254
Basque eu eu 1069 1252
Belarusian be be 1059 423 1251
Bengali – Bangladesh bn bn 2117 845
Bengali – India bn bn 1093 445
Bosnian bs bs 5146
Bulgarian bg bg 1026 402 1251
Burmese my my 1109 455
Catalan ca ca 1027 403 1252
Chinese – China zh zh-cn 2052 804
Chinese – Hong Kong SAR zh zh-hk 3076
Chinese – Macau SAR zh zh-mo 5124 1404
Chinese – Singapore zh zh-sg 4100 1004
Chinese – Taiwan zh zh-tw 1028 404
Croatian hr hr 1050 1250
Czech cs cs 1029 405 1250
Danish da da 1030 406 1252
Divehi; Dhivehi; Maldivian dv dv 1125 465
Dutch – Belgium nl nl-be 2067 813 1252
Dutch – Netherlands nl nl-nl 1043 413 1252
Edo 1126 466
English – Australia en en-au 3081 1252
English – Belize en en-bz 10249 2809 1252
English – Canada en en-ca 4105 1009 1252
English – Caribbean en en-cb 9225 2409 1252
English – Great Britain en en-gb 2057 809 1252
English – India en en-in 16393 4009
English – Ireland en en-ie 6153 1809 1252
English – Jamaica en en-jm 8201 2009 1252
English – New Zealand en en-nz 5129 1409 1252
English – Phillippines en en-ph 13321 3409 1252
English – Southern Africa en en-za 7177 1252
English – Trinidad en en-tt 11273 1252
English – United States en en-us 1033 409 1252
English – Zimbabwe en 12297 3009 1252
Estonian et et 1061 425 1257
FYRO Macedonia mk mk 1071 1251
Faroese fo fo 1080 438 1252
Farsi – Persian fa fa 1065 429 1256
Filipino 1124 464
Finnish fi fi 1035 1252
French – Belgium fr fr-be 2060 1252
French – Cameroon fr 11276
French – Canada fr fr-ca 3084 1252
French – Congo fr 9228
French – Cote d’Ivoire fr 12300
French – France fr fr-fr 1036 1252
French – Luxembourg fr fr-lu 5132 1252
French – Mali fr 13324
French – Monaco fr 6156 1252
French – Morocco fr 14348
French – Senegal fr 10252
French – Switzerland fr fr-ch 4108 1252
French – West Indies fr 7180
Frisian – Netherlands 1122 462
Gaelic – Ireland gd gd-ie 2108
Gaelic – Scotland gd gd 1084
Galician gl 1110 456 1252
Georgian ka 1079 437
German – Austria de de-at 3079 1252
German – Germany de de-de 1031 407 1252
German – Liechtenstein de de-li 5127 1407 1252
German – Luxembourg de de-lu 4103 1007 1252
German – Switzerland de de-ch 2055 807 1252
Greek el el 1032 408 1253
Guarani – Paraguay gn gn 1140 474
Gujarati gu gu 1095 447
HID (Human Interface Device) 1279
Hebrew he he 1037 1255
Hindi hi hi 1081 439
Hungarian hu hu 1038 1250
Icelandic is is 1039 1252
Igbo – Nigeria 1136 470
Indonesian id id 1057 421 1252
Italian – Italy it it-it 1040 410 1252
Italian – Switzerland it it-ch 2064 810 1252
Japanese ja ja 1041 411
Kannada kn kn 1099
Kashmiri ks ks 1120 460
Kazakh kk kk 1087 1251
Khmer km km 1107 453
Konkani 1111 457
Korean ko ko 1042 412
Kyrgyz – Cyrillic 1088 440 1251
Lao lo lo 1108 454
Latin la la 1142 476
Latvian lv lv 1062 426 1257
Lithuanian lt lt 1063 427 1257
Malay – Brunei ms ms-bn 2110 1252
Malay – Malaysia ms ms-my 1086 1252
Malayalam ml ml 1100
Maltese mt mt 1082
Manipuri 1112 458
Maori mi mi 1153 481
Marathi mr mr 1102
Mongolian mn mn 1104 450 1251
Mongolian mn mn 2128 850
Nepali ne ne 1121 461
Norwegian – Bokml nb no-no 1044 414 1252
Norwegian – Nynorsk nn no-no 2068 814 1252
Oriya or or 1096 448
Polish pl pl 1045 415 1250
Portuguese – Brazil pt pt-br 1046 416 1252
Portuguese – Portugal pt pt-pt 2070 816 1252
Punjabi pa pa 1094 446
Raeto-Romance rm rm 1047 417
Romanian – Moldova ro ro-mo 2072 818
Romanian – Romania ro ro 1048 418 1250
Russian ru ru 1049 419 1251
Russian – Moldova ru ru-mo 2073 819
Sami Lappish 1083
Sanskrit sa sa 1103
Serbian – Cyrillic sr sr-sp 3098 1251
Serbian – Latin sr sr-sp 2074 1250
Sesotho (Sutu) 1072 430
Setsuana tn tn 1074 432
Sindhi sd sd 1113 459
Sinhala; Sinhalese si si 1115
Slovak sk sk 1051 1250
Slovenian sl sl 1060 424 1250
Somali so so 1143 477
Sorbian sb sb 1070
Spanish – Argentina es es-ar 11274 1252
Spanish – Bolivia es es-bo 16394 1252
Spanish – Chile es es-cl 13322 1252
Spanish – Colombia es es-co 9226 1252
Spanish – Costa Rica es es-cr 5130 1252
Spanish – Dominican Republic es es-do 7178 1252
Spanish – Ecuador es es-ec 12298 1252
Spanish – El Salvador es es-sv 17418 1252
Spanish – Guatemala es es-gt 4106 1252
Spanish – Honduras es es-hn 18442 1252
Spanish – Mexico es es-mx 2058 1252
Spanish – Nicaragua es es-ni 19466 1252
Spanish – Panama es es-pa 6154 1252
Spanish – Paraguay es es-py 15370 1252
Spanish – Peru es es-pe 10250 1252
Spanish – Puerto Rico es es-pr 20490 1252
Spanish – Spain (Traditional) es es-es 1034 1252
Spanish – Uruguay es es-uy 14346 1252
Spanish – Venezuela es es-ve 8202 1252
Swahili sw sw 1089 441 1252
Swedish – Finland sv sv-fi 2077 1252
Swedish – Sweden sv sv-se 1053 1252
Syriac 1114
Tajik tg tg 1064 428
Tamil ta ta 1097 449
Tatar tt tt 1092 444 1251
Telugu te te 1098
Thai th th 1054
Tibetan bo bo 1105 451
Tsonga ts ts 1073 431
Turkish tr tr 1055 1254
Turkmen tk tk 1090 442
Ukrainian uk uk 1058 422 1251
Unicode UTF-8 0
Urdu ur ur 1056 420 1256
Uzbek – Cyrillic uz uz-uz 2115 843 1251
Uzbek – Latin uz uz-uz 1091 443 1254
Venda 1075 433
Vietnamese vi vi 1066 1258
Welsh cy cy 1106 452
Xhosa xh xh 1076 434
Yiddish yi yi 1085
Zulu zu zu 1077 435

 

10月 032012
 

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Math, StdCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure MakePass;
public
{ Public declarations }
end;

var
Form1: TForm1;
const
StartLEn = 1;
Endlen = 3;
srcDictString = ‘abcd’;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.MakePass;
var
nRect: Integer;
nCount: Integer;
nTotal: Double;
I, J, K: Integer;
nIndex: array of Integer;
chPass: array of char;
strTemp: string;
begin
nCount := Length(srcDictString);
for I := StartLEn to Endlen do begin
nTotal := Power(nCount, I);
SetLength(nIndex, I);
SetLength(chPass, I);
for J := 0 to Trunc(nTotal) – 1 do begin
for K := 0 to I – 1 do begin
if (nIndex[K] = nCount) then begin
nIndex[K] := 0;
if K < I – 1 then
nIndex[K + 1] := nIndex[K + 1] + 1;
end;
end;

for K := 0 to I – 1 do begin
chPass[I – K – 1] := srcDictString[nIndex[K] + 1];
end;

nIndex[0] := nIndex[0] + 1;
strtemp := string(@chPass[0]);
Memo1.Lines.Add(strTemp);
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
MakePass;
end;

end.

10月 032012
 

  今天打开IIS发现IIS无法启动了,在控制面板-》管理工具-》计算机管理-》事件查看器-》系统中发现在,W3SVC服务发生错误。错误内容为:

  服务无法绑定实例 1。返回数据是错误代码。

  后来在网上查询是80端口被其他程序占用,导致W3SVC无法正常启动,而IIS也无法启动。

  Skype和迅雷有可能导致此问题。

  解决办法:
  1、skype,关掉Skype或者修改其设置,在菜单Tools->Options中,点击Advanced选项卡,Connection子选项,“Use port 80 and 443 as alternatives for incoming connections”上的对勾去掉。
  2、迅雷,关掉。

 Posted by on 2012-10-03  标签:
10月 032012
 

 

10月 032012
 

1、通过IP取MAC地址

uses
WinSock;

Function sendarp(ipaddr:ulong;
temp:dword;
ulmacaddr:pointer;
ulmacaddrleng:pointer) : DWord; StdCall; External ‘Iphlpapi.dll’ Name ‘SendARP’;

procedure TForm1.Button1Click(Sender: TObject);
var
myip:ulong;
mymac:array[0..5] of byte;
mymaclength:ulong;
r:integer;
begin
myip:=inet_addr(PChar(‘192.168.6.180’));
mymaclength:=length(mymac);
r:=sendarp(myip,0,@mymac,@mymaclength);
label1.caption:=’errorcode:’+inttostr(r);
label2.caption:=format(‘%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x’,[mymac[0],mymac[1],mymac[2],mymac[3],mymac[4],mymac[5]]);
end;
2、取MAC地址 (含多网卡)

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
WinSock, StdCtrls;

Const
MAX_HOSTNAME_LEN = 128; { from IPTYPES.H }
MAX_DOMAIN_NAME_LEN = 128;
MAX_SCOPE_ID_LEN = 256;
MAX_ADAPTER_NAME_LENGTH = 256;
MAX_ADAPTER_DESCRIPTION_LENGTH = 128;
MAX_ADAPTER_ADDRESS_LENGTH = 8;

Type
TIPAddressString = Array[0..4*4-1] of Char;

PIPAddrString = ^TIPAddrString;
TIPAddrString = Record
Next : PIPAddrString;
IPAddress : TIPAddressString;
IPMask : TIPAddressString;
Context : Integer;
End;

PFixedInfo = ^TFixedInfo;
TFixedInfo = Record { FIXED_INFO }
HostName : Array[0..MAX_HOSTNAME_LEN+3] of Char;
DomainName : Array[0..MAX_DOMAIN_NAME_LEN+3] of Char;
CurrentDNSServer : PIPAddrString;
DNSServerList : TIPAddrString;
NodeType : Integer;
ScopeId : Array[0..MAX_SCOPE_ID_LEN+3] of Char;
EnableRouting : Integer;
EnableProxy : Integer;
EnableDNS : Integer;
End;

PIPAdapterInfo = ^TIPAdapterInfo;
TIPAdapterInfo = Record { IP_ADAPTER_INFO }
Next : PIPAdapterInfo;
ComboIndex : Integer;
AdapterName : Array[0..MAX_ADAPTER_NAME_LENGTH+3] of Char;
Description : Array[0..MAX_ADAPTER_DESCRIPTION_LENGTH+3] of Char;
AddressLength : Integer;
Address : Array[1..MAX_ADAPTER_ADDRESS_LENGTH] of Byte;
Index : Integer;
_Type : Integer;
DHCPEnabled : Integer;
CurrentIPAddress : PIPAddrString;
IPAddressList : TIPAddrString;
GatewayList : TIPAddrString;
DHCPServer : TIPAddrString;
HaveWINS : Bool;
PrimaryWINSServer : TIPAddrString;
SecondaryWINSServer : TIPAddrString;
LeaseObtained : Integer;
LeaseExpires : Integer;
End;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure GetAdapterInformation;
public
{ Public declarations }
end;

var
Form1: TForm1;

Function sendarp(ipaddr:ulong;
temp:dword;
ulmacaddr:pointer;
ulmacaddrleng:pointer) : DWord; StdCall;

implementation

{$R *.dfm}

Function sendarp; External ‘Iphlpapi.dll’ Name ‘SendARP’;
Function GetAdaptersInfo(AI : PIPAdapterInfo; Var BufLen : Integer) : Integer;
StdCall; External ‘iphlpapi.dll’ Name ‘GetAdaptersInfo’;

procedure TForm1.GetAdapterInformation;
Var
AI,Work : PIPAdapterInfo;
Size : Integer;
Res : Integer;
I : Integer;

Function MACToStr(ByteArr : PByte; Len : Integer) : String;
Begin
Result := ”;
While (Len > 0) do Begin
Result := Result+IntToHex(ByteArr^,2)+’-‘;
ByteArr := Pointer(Integer(ByteArr)+SizeOf(Byte));
Dec(Len);
End;
SetLength(Result,Length(Result)-1); { remove last dash }
End;

Function GetAddrString(Addr : PIPAddrString) : String;
Begin
Result := ”;
While (Addr <> nil) do Begin
Result := Result+’A: ‘+Addr^.IPAddress+’ M: ‘+Addr^.IPMask+#13;
Addr := Addr^.Next;
End;
End;

Function TimeTToDateTimeStr(TimeT : Integer) : String;
Const UnixDateDelta = 25569; { days between 12/31/1899 and 1/1/1970 }
Var
DT : TDateTime;
TZ : TTimeZoneInformation;
Res : DWord;

Begin
If (TimeT = 0) Then Result := ”
Else Begin
{ Unix TIME_T is secs since 1/1/1970 }
DT := UnixDateDelta+(TimeT / (24*60*60)); { in UTC }
{ calculate bias }
Res := GetTimeZoneInformation(TZ);
If (Res = TIME_ZONE_ID_INVALID) Then RaiseLastWin32Error;
If (Res = TIME_ZONE_ID_STANDARD) Then Begin
DT := DT-((TZ.Bias+TZ.StandardBias) / (24*60));
Result := DateTimeToStr(DT)+’ ‘+WideCharToString(TZ.StandardName);
End
Else Begin { daylight saving time }
DT := DT-((TZ.Bias+TZ.DaylightBias) / (24*60));
Result := DateTimeToStr(DT)+’ ‘+WideCharToString(TZ.DaylightName);
End;
End;
End;

begin
Memo1.Lines.Clear;
Size := 5120;
GetMem(AI,Size);
Res := GetAdaptersInfo(AI,Size);
If (Res <> ERROR_SUCCESS) Then Begin
SetLastError(Res);
RaiseLastWin32Error;
End;
With Memo1,Lines do Begin
Work := AI;
I := 1;
Repeat
Add(”);
Add(‘Adapter ‘ + IntToStr(I));
Add(‘ ComboIndex: ‘+IntToStr(Work^.ComboIndex));
Add(‘ Adapter name: ‘+Work^.AdapterName);
Add(‘ Description: ‘+Work^.Description);
Add(‘ Adapter address: ‘+MACToStr(@Work^.Address,Work^.AddressLength));
Add(‘ Index: ‘+IntToStr(Work^.Index));
Add(‘ Type: ‘+IntToStr(Work^._Type));
Add(‘ DHCP: ‘+IntToStr(Work^.DHCPEnabled));
Add(‘ Current IP: ‘+GetAddrString(Work^.CurrentIPAddress));
Add(‘ IP addresses: ‘+GetAddrString(@Work^.IPAddressList));
Add(‘ Gateways: ‘+GetAddrString(@Work^.GatewayList));
Add(‘ DHCP servers: ‘+GetAddrString(@Work^.DHCPServer));
Add(‘ Has WINS: ‘+IntToStr(Integer(Work^.HaveWINS)));
Add(‘ Primary WINS: ‘+GetAddrString(@Work^.PrimaryWINSServer));
Add(‘ Secondary WINS: ‘+GetAddrString(@Work^.SecondaryWINSServer));
Add(‘ Lease obtained: ‘+TimeTToDateTimeStr(Work^.LeaseObtained));
Add(‘ Lease expires: ‘+TimeTToDateTimeStr(Work^.LeaseExpires));
Inc(I);
Work := Work^.Next;
Until (Work = nil);
End;
FreeMem(AI);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
GetAdapterInformation;
end;

end.
方法2

uses nb30;

function NBGetAdapterAddress(a: Integer): string;
var
NCB: TNCB; // Netbios control block //NetBios控制块
ADAPTER: TADAPTERSTATUS; // Netbios adapter status//取网卡状态
LANAENUM: TLANAENUM; // Netbios lana
intIdx: Integer; // Temporary work value//临时变量
cRC: Char; // Netbios return code//NetBios返回值
strTemp: string; // Temporary string//临时变量
begin
Result := ”;

try
ZeroMemory(@NCB, SizeOf(NCB)); // Zero control blocl

NCB.ncb_command := Chr(NCBENUM); // Issue enum command
cRC := NetBios(@NCB);

NCB.ncb_buffer := @LANAENUM; // Reissue enum command
NCB.ncb_length := SizeOf(LANAENUM);
cRC := NetBios(@NCB);
if Ord(cRC) <> 0 then
exit;

ZeroMemory(@NCB, SizeOf(NCB)); // Reset adapter
NCB.ncb_command := Chr(NCBRESET);
NCB.ncb_lana_num := LANAENUM.lana[a];
cRC := NetBios(@NCB);
if Ord(cRC) <> 0 then
exit;
ZeroMemory(@NCB, SizeOf(NCB)); // Get adapter address
NCB.ncb_command := Chr(NCBASTAT);
NCB.ncb_lana_num := LANAENUM.lana[a];
StrPCopy(NCB.ncb_callname, ‘*’);
NCB.ncb_buffer := @ADAPTER;
NCB.ncb_length := SizeOf(ADAPTER);
cRC := NetBios(@NCB);

strTemp := ”; // Convert it to string
for intIdx := 0 to 5 do
strTemp := strTemp + InttoHex(Integer(ADAPTER.adapter_address[intIdx]), 2);
Result := strTemp;
finally
end;
end;

9月 252012
 

Delphi code to get statusbar text from other process