Thursday, 22 November 2018
How to Create CAPTCHA Protection using PHP and AJAX
https://webcheatsheet.com/PHP/create_captcha_protection.php#conclusion
Thursday, 25 October 2018
PathDelim VS DirectorySeparatorChar
System.IOUtils.TPath.GetDocumentsPath + System.SysUtils.PathDelim + 'myfile';
PathDelim VS DirectorySeparatorChar
System.SysUtils.PathDelim
was introduced in Delphi 6 / Kylix 1, as a means to enable the writing
of platform independent code. The introduction of Kylix, the original
Delphi Linux compiler, meant that for the first time Delphi code
executed on a *nix platform, as well as its original target of Windows. System.IOUtils.TPath.DirectorySeparatorChar
is part of the IOUtils
unit that was introduced more recently to support the current wave of
cross-platform tooling, which supports MacOS, iOS, Android and will soon
encompass Linux once more. Where you have a choice between
System.SysUtils
and System.IOUtils
, you are generally expected to use the latter. The System.IOUtils
is the cross-platform unit for file system support. That said, you commonly would not use DirectorySeparatorChar
directly, but instead would use methods like System.IOUtils.TPath.Combine
. --David Heffernan
http://androidcookie.com/android-firemonkey.html
Sunday, 21 October 2018
Saturday, 20 October 2018
Delphi - how to get a list of all files of directory
Var
Path : String;
SR : TSearchRec;
DirList : TStrings;
begin
if OpenPictureDialog1.Execute then
begin
Path:=ExtractFileDir(OpenPictureDialog1.FileName); //Get the path of the selected file
DirList:=TStringList.Create;
try
if FindFirst(Path + '*.*', faArchive, SR) = 0 then
begin
repeat
DirList.Add(SR.Name); //Fill the list
until FindNext(SR) <> 0;
FindClose(SR);
end;
//do your stuff
finally
DirList.Free;
end;
end;
end;
Wednesday, 26 September 2018
工作站不必笨重,聯想在台灣推出 ThinkPad P1 與 ThinkStation P330 Tiny
聯想今天在台灣發表了以 ThinkPad P1 和 ThinkStation P330 Tiny 為代表的新一代工作站機種,大大地豐富了工作線站的產品。在此之前聯想的工作站筆電雖然有著怪物級的效能,但也同樣有著怪物級的重量,這次的 ThinkPad P1 則是參考了 ThinkPad X1 Carbon 的各種減重技巧與設計,讓搭載了 i7-8850H / Xeon E-2176M 與最高 NVIDIA Quadro P2000 的 15.6 吋機身,也能把重量壓在了 1.7kg。眼尖的讀者可能會發現它與稍晚發表的 ThinkPad X1 Extreme 非常相似,可以看做是使用工作站級顯卡的兄弟機吧。雖然說不是 X1 Carbon 等級的輕,但對於需要帶著工作站四處跑的專業人士來說,也是減輕了不少負擔了。
最後,是超迷你工作站 P330 Tiny,前代 P320 Mini 的規格升級版。雖然說外觀上並沒有太大的變化,但這仍然是個相當驚人的小盒子,配備了 Core i7-8700T 處理器、Quadro P620 顯卡(或是不裝顯卡的話,可以用這空間來放一顆額外的 2.5 吋 SSD)、 32GB M.2 SSD、及最高 32GB 的記憶體,並且會在稍後提供 Quadro P1000 與 64GB 記憶體的選項。Quadro 獨顯的採用,也讓它可以輸出到最多六個螢幕之多呢。
https://chinese.engadget.com/2018/09/26/thinkpad-p1-thinkstation-p330-tiny-tw/
最後,是超迷你工作站 P330 Tiny,前代 P320 Mini 的規格升級版。雖然說外觀上並沒有太大的變化,但這仍然是個相當驚人的小盒子,配備了 Core i7-8700T 處理器、Quadro P620 顯卡(或是不裝顯卡的話,可以用這空間來放一顆額外的 2.5 吋 SSD)、 32GB M.2 SSD、及最高 32GB 的記憶體,並且會在稍後提供 Quadro P1000 與 64GB 記憶體的選項。Quadro 獨顯的採用,也讓它可以輸出到最多六個螢幕之多呢。
https://chinese.engadget.com/2018/09/26/thinkpad-p1-thinkstation-p330-tiny-tw/
Friday, 21 September 2018
luren.jia outlook
tapiro sina
xiaoyong.my gmail
silyong.p gmail
yongpoh ymail
silyong.p icloud
tapiro sina
xiaoyong.my gmail
silyong.p gmail
yongpoh ymail
silyong.p icloud
Monday, 10 September 2018
網路位址轉換
在電腦網路中,網路位址轉換(Network Address Translation,縮寫為NAT),也叫做網路掩蔽或者IP掩蔽(IP masquerading),是一種在IP封包通過路由器或防火牆時重寫來源IP位址或目的IP地址的技術。這種技術被普遍使用在有多台主機但只通過一個公有IP位址存取因特網的私有網路中。它是一個方便且得到了廣泛應用的技術。當然,NAT也讓主機之間的通訊變得複雜,導致了通訊效率的降低。
https://zh.wikipedia.org/wiki/%E7%BD%91%E7%BB%9C%E5%9C%B0%E5%9D%80%E8%BD%AC%E6%8D%A2
How Network Address Translation Works
https://computer.howstuffworks.com/nat.htm/printable
UDP打洞
描述
通過UDP路由驗證實現NAT穿越是一種在處於使用了NAT的私有網絡中的Internet主機之間建立雙向UDP連接的方法。由於NAT的行為是非標準化的,因此它並不能應用於所有類型的NAT。其基本思想是這樣的:讓位於NAT後的兩台主機都與處於公共地址空間的、眾所周知的第三台伺服器相連,然後,一旦NAT設備建立好UDP狀態信息就轉為直接通信,並寄希望於NAT設備會在分組其實是從另外一個主機傳送過來的情況下仍然保持當前狀態。
這項技術需要一個圓錐型NAT設備才能夠正常工作。對稱型NAT不能使用這項技術。
這項技術在P2P軟體和VoIP電話領域被廣泛採用。它是Skype用以繞過防火牆和NAT設備的技術之一。
相同的技術有時還被用於TCP連接——儘管遠沒有UDP成功。
算法
假設有兩台分別處於各自的私有網絡中的主機:A和B;N1和N2是兩個網絡的NAT設備,分別擁有IP位址P1和P2;S是一個使用了一個眾所周知的、從全球任何地方都能訪問得到的IP位址的公共伺服器步驟一:A和B分別和S建立UDP連接;NAT設備N1和N2創建UDP轉換狀態並分配臨時的外部埠號
步驟二:S檢查UDP包,看A和B的埠是否是正在被使用的(否則的話N1和N2應該是應用了埠隨機分配,這會讓路由驗證變得更麻煩)
步驟三:如果埠不是隨機化的,那麼A和B各自選擇埠X和Y,並告知S。S會讓A發送UDP包到P2:Y,讓B發送UDP包到P1:X
步驟四:A和B通過轉換好的IP位址和埠直接聯繫到對方的NAT設備;
UDP broadcast
UDP broadcast is a technique that allows sending UDP datagram from a single source to all computers in a LAN. In order to send a UDP datagram addressed to all computers in the local area network it needs to be sent to a special address called the Broadcast address.
[worked] Udp Send / Receive
Sender
unit UnitUDPClientAndroid;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdUDPClient1: TIdUDPClient;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
with IdUDPClient1 do
begin
Host := '192.168.0.5';
Port := 69;
send('filename.txt');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
IdUDPClient1.Active := true;
end;
end.
// -----------------------------------------------------------------------------------------------------------
Receiver
unit UnitServer;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdComponent,
IdIPWatch, IdBaseComponent, IdUDPBase, IdUDPServer, FMX.Controls.Presentation,
FMX.ScrollBox, FMX.Memo, IdGlobal, IdSocketHandle;
type
TForm1 = class(TForm)
IdUDPServer1: TIdUDPServer;
IdIPWatch1: TIdIPWatch;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyUDPMessage : String;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Add(IdIPWatch1.LocalIP);
Form1.IdUDPServer1.DefaultPort := 69;
Form1.IdUDPServer1.Active := True;
Form1.IdUDPServer1.OnUDPRead := IdUDPServer1UDPRead;
end;
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
begin
MyUDPmessage := BytesToString(AData);
Memo1.Lines.Add(MyUDPMessage);
end;
end.
unit UnitUDPClientAndroid;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdUDPClient1: TIdUDPClient;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
with IdUDPClient1 do
begin
Host := '192.168.0.5';
Port := 69;
send('filename.txt');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
IdUDPClient1.Active := true;
end;
end.
// -----------------------------------------------------------------------------------------------------------
Receiver
unit UnitServer;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdComponent,
IdIPWatch, IdBaseComponent, IdUDPBase, IdUDPServer, FMX.Controls.Presentation,
FMX.ScrollBox, FMX.Memo, IdGlobal, IdSocketHandle;
type
TForm1 = class(TForm)
IdUDPServer1: TIdUDPServer;
IdIPWatch1: TIdIPWatch;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyUDPMessage : String;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Add(IdIPWatch1.LocalIP);
Form1.IdUDPServer1.DefaultPort := 69;
Form1.IdUDPServer1.Active := True;
Form1.IdUDPServer1.OnUDPRead := IdUDPServer1UDPRead;
end;
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
begin
MyUDPmessage := BytesToString(AData);
Memo1.Lines.Add(MyUDPMessage);
end;
end.
UDP
用户数据报协议(英语:User Datagram Protocol,縮寫為UDP),又稱使用者資料包協定,是一个简单的面向数据报的传输层协议,正式規範為RFC 768。
在TCP/IP模型中,UDP为网络层以上和应用层以下提供了一个简单的接口。UDP只提供数据的不可靠传递,它一旦把应用程序发给网络层的数据发送出去,就不保留数据备份(所以UDP有时候也被认为是不可靠的数据报协议)。UDP在IP数据报的头部仅仅加入了复用和数据校验(字段)。
UDP首部字段由4个部分组成,其中两个是可选的。各16bit的來源端口和目的端口用来标记发送和接受的应用进程。因为UDP不需要应答,所以來源端口是可选的,如果來源端口不用,那么置为零。在目的端口后面是长度固定的以字节为单位的长度域,用来指定UDP数据报包括数据部分的长度,长度最小值为8byte。首部剩下地16bit是用来对首部和数据部分一起做校驗和(Checksum)的,这部分是可选的,但在实际应用中一般都使用这一功能。
由于缺乏可靠性且屬於非連接導向協定,UDP应用一般必须允许一定量的丢包、出错和复制貼上。但有些应用,比如TFTP,如果需要则必须在应用层增加根本的可靠机制。但是绝大多数UDP应用都不需要可靠机制,甚至可能因为引入可靠机制而降低性能。流媒體(串流技術)、即时多媒体游戏和IP电话(VoIP)一定就是典型的UDP应用。如果某个应用需要很高的可靠性,那么可以用传输控制协议(TCP协议)来代替UDP。
由于缺乏拥塞控制(congestion control),需要基于网络的机制来减少因失控和高速UDP流量负荷而导致的拥塞崩溃效应。换句话说,因为UDP发送者不能够检测拥塞,所以像使用包队列和丢弃技术的路由器这样的网络基本设备往往就成为降低UDP过大通信量的有效工具。数据报拥塞控制协议(DCCP)设计成通过在诸如流媒体类型的高速率UDP流中,增加主机拥塞控制,来减小这个潜在的问题。
典型网络上的众多使用UDP协议的关键应用一定程度上是相似的。这些应用包括域名系统(DNS)、简单网络管理协议(SNMP)、动态主机配置协议(DHCP)、路由信息协议(RIP)和某些影音串流服務等等。
在TCP/IP模型中,UDP为网络层以上和应用层以下提供了一个简单的接口。UDP只提供数据的不可靠传递,它一旦把应用程序发给网络层的数据发送出去,就不保留数据备份(所以UDP有时候也被认为是不可靠的数据报协议)。UDP在IP数据报的头部仅仅加入了复用和数据校验(字段)。
UDP首部字段由4个部分组成,其中两个是可选的。各16bit的來源端口和目的端口用来标记发送和接受的应用进程。因为UDP不需要应答,所以來源端口是可选的,如果來源端口不用,那么置为零。在目的端口后面是长度固定的以字节为单位的长度域,用来指定UDP数据报包括数据部分的长度,长度最小值为8byte。首部剩下地16bit是用来对首部和数据部分一起做校驗和(Checksum)的,这部分是可选的,但在实际应用中一般都使用这一功能。
由于缺乏可靠性且屬於非連接導向協定,UDP应用一般必须允许一定量的丢包、出错和复制貼上。但有些应用,比如TFTP,如果需要则必须在应用层增加根本的可靠机制。但是绝大多数UDP应用都不需要可靠机制,甚至可能因为引入可靠机制而降低性能。流媒體(串流技術)、即时多媒体游戏和IP电话(VoIP)一定就是典型的UDP应用。如果某个应用需要很高的可靠性,那么可以用传输控制协议(TCP协议)来代替UDP。
由于缺乏拥塞控制(congestion control),需要基于网络的机制来减少因失控和高速UDP流量负荷而导致的拥塞崩溃效应。换句话说,因为UDP发送者不能够检测拥塞,所以像使用包队列和丢弃技术的路由器这样的网络基本设备往往就成为降低UDP过大通信量的有效工具。数据报拥塞控制协议(DCCP)设计成通过在诸如流媒体类型的高速率UDP流中,增加主机拥塞控制,来减小这个潜在的问题。
典型网络上的众多使用UDP协议的关键应用一定程度上是相似的。这些应用包括域名系统(DNS)、简单网络管理协议(SNMP)、动态主机配置协议(DHCP)、路由信息协议(RIP)和某些影音串流服務等等。
Thursday, 23 August 2018
Wednesday, 22 August 2018
VoiceChat with FireMonkey XE6 (Delphi XE6) on Win, Android
https://www.youtube.com/watch?v=oa2x7V4y3h0
Delphi中UDP协议通讯
http://jicai.blog.163.com/blog/static/2619879200801091439624/
https://blog.csdn.net/csdnmyaccp_s2/article/details/52541946
Tuesday, 21 August 2018
Wednesday, 15 August 2018
Berastagi
Berastagi (Dutch: Brastagi), meaning "rice store", is a town and district of Karo Regency situated on a crossroads on the main route linking the Karo highlands of Northern Sumatra to the coastal city of Medan.
Berastagi town is located around 66 kilometers (41 miles) south of
Medan and about 1,300 meters (4300 feet) above sea level. The village
rose to significance when Dutch settlers in Sumatra opened a boarding school there in the 1920s.
What transportation options are there available (buses, shared taxi, taxi, or else)?
What transportation options are there available (buses, shared taxi, taxi, or else)?
https://www.tripsavvy.com/things-to-do-at-lake-toba-1458263
https://wikitravel.org/en/Lake_Toba
https://www.backpackers.com.tw/forum/archive/index.php/t-805583.html
https://travel.qunar.com/p-pl5221631
http://ephilip721.blogspot.com/2018/03/blog-post.html
As far as I know there are two possible ways to get to Lake Toba from Medan.
Further info: SAMPRI buses are the local public buses that seem to be the most 'official' ones. The price is fixed and told straight-forward, no need for bargaining. At some point shortly after starting the journey (on our way to Banyak islands) the bus drivr stops at a booth where you purchase your ticket and get a receipt with price and stamp.
- The easiest way to do this journey is to travel on a tourist minibus. It is a bit more expensive than the public transport option but it also gets you faster to your destination and you do not have to worry about transfering buses, finding the right one, waiting for it to leave, etc. You will travel by road from Medan to Parapat, you catch the bus from the Pinang Baris bus station in Medan. The price should be around 90,000 Rp. From Parapat you will be dropped off at the port, from where you will take a ferry to Palau Samosir, the island in the middle of the lake. The ferry costs 15'000 Rp. We were actually travelling from Bukit Lawang to Samosir island. We took the tourist bus for 230.000 Rps. The bus left from Bukit Lawang at 8.30 am and arrived at Medan at around 11.00 am. After a short break we continued on the road, reaching Berastagi at 1.30pm. After another break we then headed to Parapat, another 3 hr drive, so we arrived there at 5pm. Then we had to wait for the ferry. The ferry ticket was included in the total price we paid. To go from Bukit Lawang to Berastagi, same journey costs 170,000 Rps.
- There is another way to reach Danau Toba by using public transport. We did not go for this option, so I do not know the prices, but it is definitely cheaper than the above option. It is also a bit more complicated to reach the destination, timewise. You can take a public bus from Medan to Berastagi, from there catch an opelet to Kabanjahe, then transfer to a bus to Pematangsiantar and then to another bus heading to Parapat.
Further info: SAMPRI buses are the local public buses that seem to be the most 'official' ones. The price is fixed and told straight-forward, no need for bargaining. At some point shortly after starting the journey (on our way to Banyak islands) the bus drivr stops at a booth where you purchase your ticket and get a receipt with price and stamp.
https://www.tripsavvy.com/things-to-do-at-lake-toba-1458263
https://wikitravel.org/en/Lake_Toba
https://www.backpackers.com.tw/forum/archive/index.php/t-805583.html
https://travel.qunar.com/p-pl5221631
http://ephilip721.blogspot.com/2018/03/blog-post.html
Wednesday, 8 August 2018
IM即时通讯实现原理
QQ就是使用UDP协议进行发送和接收消息的。当你的机器安装了OICQ以后,实际上,你既是服务端(Server),又是客户端(Client)。当你登录OICQ时,你的OICQ作为Client连接到腾讯公司的主服务器上,当你看谁在线时,你的OICQ又一次作为Client从QQ Server上读取在线网友名单。当你和你的OICQ伙伴进行聊天时,如果你和对方的连接比较稳定,你和他的聊天内容都是以UDP的形式,在计算机之间传 送。如果你和对方的连接不是很稳定,QQ服务器将为你们的聊天内容进行中转。其他的即时通信软件原理与此大同小异。
https://www.cnblogs.com/dubo-/p/5586036.html
Monday, 16 July 2018
如何判断电风扇的电容坏了?
知识拓展:
电风扇电容该怎么接线?第一步,通过对3根输入线头任意两根之间3次测量确定最大电阻的两根,剩下的一根为公共零线;第二步,再测出两根中对公共零线电阻较大的那根线接电容。
电风扇出现反转,究竟是什么原因导致的?一般是由于电源的极性接反了造成的。正确的接线,可参考下图:
Thursday, 28 June 2018
大便语录
大便语录
人窮沒事,怕是窮腦袋
当你有钱时, 你往往会选择风险较低的投资; 当你没钱时, 你喜欢风险较高的投资, 期望快速致富。可是选择要快速致富的人。往往都不会成为有钱人。
老板去普吉岛, 打工仔去冰岛; 到头来, 打工仔, 还是打工仔, 老板还是老板
人窮沒事,怕是窮腦袋
当你有钱时, 你往往会选择风险较低的投资; 当你没钱时, 你喜欢风险较高的投资, 期望快速致富。可是选择要快速致富的人。往往都不会成为有钱人。
老板去普吉岛, 打工仔去冰岛; 到头来, 打工仔, 还是打工仔, 老板还是老板
Thursday, 21 June 2018
Send And Fetch SMS Messages With Delphi Firemonkey On Android
http://www.fmxexpress.com/send-and-fetch-sms-messages-with-delphi-firemonkey-on-android/
Thursday, 14 June 2018
擦干汗再进冷气房 否则易致汗腺闭塞
在炎热的天气,人们汗流浃背时习惯立即擦掉。这种习惯好吗?要视乎接下的状况——如果要继续出汗的,还是别擦了;如果马上进入室内空调,那要尽快擦干。
如果还将继续出汗,即体温不能马上降,所处环境温度变化不大,那不宜擦汗。这么做的原因是要利用体表汗水蒸发散热,帮助皮肤降低体温。
人体散热主要是通过皮肤表面的辐射、传导、对流和蒸发汗液来实现。在高温的条件下人体产热增加时,汗腺就会分泌出大量汗液,这些汗液附着在皮肤表面,当汗液从液态转化为气态时,就会带走大量的热量,可起到散热降温的作用。因此如果出汗后立即擦掉,就不能发挥其蒸发散热的作用;同时由于热量没有散发,汗腺还会继续分泌汗液,体内的盐分、维生素等也会随之消耗掉,对健康不利。
如果当身体皮肤出汗后,进入冷气w房,最好是用干毛巾或温热毛巾擦除汗湿,不宜用冷水或冷毛巾擦,并避开冷风直吹,以免毛细血管开放时,汗腺被闭塞。
皮肤受到冷的刺激,毛孔会紧闭,毛细血管也会收缩,体内积热散发不出来,此时人体会产生闷热的感觉。若用温热水,皮肤表面受到热的刺激,毛孔可迅速张开,毛细血管随之扩张,热量就会更多更快地散发出来,人体很快就会感到凉爽舒适。
热天适度出汗,是身体平衡机体内外温度及排出毒素必不可少的一种排泄途径,但过度出汗,则不利身体健康。
勤洗澡换内衣裤
想减少不必要的多汗,最重要的是讲究卫生,勤洗澡,勤换内衣裤和鞋袜,穿吸汗透气性好的衣物,以便汗液及时蒸发,减少汗液在体表的停留。
热天身体出汗后,不可贪一时凉快,不要用湿冷毛巾擦皮肤和冷水淋浴,而需要用干或热毛巾擦去汗湿,休息片刻,让汗孔慢慢收缩后,再进冷气室,或洗热水澡。此外,热天汗出太多,务必注意及时补充水分。
如果还将继续出汗,即体温不能马上降,所处环境温度变化不大,那不宜擦汗。这么做的原因是要利用体表汗水蒸发散热,帮助皮肤降低体温。
人体散热主要是通过皮肤表面的辐射、传导、对流和蒸发汗液来实现。在高温的条件下人体产热增加时,汗腺就会分泌出大量汗液,这些汗液附着在皮肤表面,当汗液从液态转化为气态时,就会带走大量的热量,可起到散热降温的作用。因此如果出汗后立即擦掉,就不能发挥其蒸发散热的作用;同时由于热量没有散发,汗腺还会继续分泌汗液,体内的盐分、维生素等也会随之消耗掉,对健康不利。
如果当身体皮肤出汗后,进入冷气w房,最好是用干毛巾或温热毛巾擦除汗湿,不宜用冷水或冷毛巾擦,并避开冷风直吹,以免毛细血管开放时,汗腺被闭塞。
皮肤受到冷的刺激,毛孔会紧闭,毛细血管也会收缩,体内积热散发不出来,此时人体会产生闷热的感觉。若用温热水,皮肤表面受到热的刺激,毛孔可迅速张开,毛细血管随之扩张,热量就会更多更快地散发出来,人体很快就会感到凉爽舒适。
热天适度出汗,是身体平衡机体内外温度及排出毒素必不可少的一种排泄途径,但过度出汗,则不利身体健康。
勤洗澡换内衣裤
想减少不必要的多汗,最重要的是讲究卫生,勤洗澡,勤换内衣裤和鞋袜,穿吸汗透气性好的衣物,以便汗液及时蒸发,减少汗液在体表的停留。
热天身体出汗后,不可贪一时凉快,不要用湿冷毛巾擦皮肤和冷水淋浴,而需要用干或热毛巾擦去汗湿,休息片刻,让汗孔慢慢收缩后,再进冷气室,或洗热水澡。此外,热天汗出太多,务必注意及时补充水分。
Thursday, 7 June 2018
doit_onkeypress(event)
<html>
<BODY onLoad="document.getElementById('usr').focus();" bgcolor="#CCCCCC">
<br><br>
<p align=center>
<table width=400>
<form name="myForm" action="#" onsubmit="return check()" method="post">
<tr>
<td>Phone</td>
</tr>
<tr>
<td><input type="text" name="usr" id="usr"></td>
</tr>
<tr>
<td>Password</td>
</tr>
<tr>
<td><input type="password" name="passwd" id="passwd" onkeypress="doit_onkeypress(event);"/></td>
</tr>
<tr><td> </td></tr>
<tr><td id="msg"></td></tr>
<tr>
<td> <input type="submit" value="Log in"></td>
</tr>
</form>
<tr><td> </td></tr>
<tr>
<td><a href="mima/rst_mima.php">Forget Password / Create account</a></td>
</tr>
</table>
</p>
</body>
<script language="JavaScript">
function doit_onkeypress(event){
alert(event.keyCode);
if (event.keyCode == 13){
alert('');
/* document.myForm.submit(); */
}
}
<BODY onLoad="document.getElementById('usr').focus();" bgcolor="#CCCCCC">
<br><br>
<p align=center>
<table width=400>
<form name="myForm" action="#" onsubmit="return check()" method="post">
<tr>
<td>Phone</td>
</tr>
<tr>
<td><input type="text" name="usr" id="usr"></td>
</tr>
<tr>
<td>Password</td>
</tr>
<tr>
<td><input type="password" name="passwd" id="passwd" onkeypress="doit_onkeypress(event);"/></td>
</tr>
<tr><td> </td></tr>
<tr><td id="msg"></td></tr>
<tr>
<td> <input type="submit" value="Log in"></td>
</tr>
</form>
<tr><td> </td></tr>
<tr>
<td><a href="mima/rst_mima.php">Forget Password / Create account</a></td>
</tr>
</table>
</p>
</body>
<script language="JavaScript">
function doit_onkeypress(event){
alert(event.keyCode);
if (event.keyCode == 13){
alert('');
/* document.myForm.submit(); */
}
}
Friday, 1 June 2018
[worked]...enable the Return key in a TWebbrowser?
http://www.swissdelphicenter.com/en/showcode.php?id=1055
Problem:
Web forms that have multiline text boxes and/or Submit buttons do not
respond to the Enter key when displayed on a TWebbrowser.
Also when browsing local folders, some keys don't respond.
How to solve it:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ActiveX;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FOleInPlaceActiveObject: IOleInPlaceActiveObject;
procedure MsgHandler(var Msg: TMsg; var Handled: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormDestroy(Sender: TObject);
begin
FOleInPlaceActiveObject := nil;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MsgHandler;
end;
procedure TForm1.MsgHandler(var Msg: TMsg; var Handled: Boolean);
const
StdKeys = [VK_BACK, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT];
var IOIPAO: IOleInPlaceActiveObject;
Dispatch: IDispatch;
begin
if WebBrowser1 = nil then
begin
Handled := False;
Exit;
end;
Handled := (IsDialogMessage(WebBrowser1.Handle, Msg) = True);
if (Handled) and (not WebBrowser1.Busy) then
begin
if FOleInPlaceActiveObject = nil then
begin
Dispatch := WebBrowser1.Application;
if Dispatch <> nil then
begin
Dispatch.QueryInterface(IOleInPlaceActiveObject, IOIPAO);
if IOIPAO <> nil then FOleInPlaceActiveObject := IOIPAO;
end;
end;
if FOleInPlaceActiveObject <> nil then
if ((Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP)) and
(Msg.wParam in StdKeys) then
//nothing - do not pass on Backspace, Left, Right, Up, Down arrows
else FOleInPlaceActiveObject.TranslateAccelerator(Msg);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Webbrowser1.Navigate('www.SwissDelphiCenter.ch');
end;
initialization
OleInitialize(nil);
finalization
OleUninitialize
end.
Problem:
Web forms that have multiline text boxes and/or Submit buttons do not
respond to the Enter key when displayed on a TWebbrowser.
Also when browsing local folders, some keys don't respond.
How to solve it:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ActiveX;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FOleInPlaceActiveObject: IOleInPlaceActiveObject;
procedure MsgHandler(var Msg: TMsg; var Handled: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormDestroy(Sender: TObject);
begin
FOleInPlaceActiveObject := nil;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MsgHandler;
end;
procedure TForm1.MsgHandler(var Msg: TMsg; var Handled: Boolean);
const
StdKeys = [VK_BACK, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT];
var IOIPAO: IOleInPlaceActiveObject;
Dispatch: IDispatch;
begin
if WebBrowser1 = nil then
begin
Handled := False;
Exit;
end;
Handled := (IsDialogMessage(WebBrowser1.Handle, Msg) = True);
if (Handled) and (not WebBrowser1.Busy) then
begin
if FOleInPlaceActiveObject = nil then
begin
Dispatch := WebBrowser1.Application;
if Dispatch <> nil then
begin
Dispatch.QueryInterface(IOleInPlaceActiveObject, IOIPAO);
if IOIPAO <> nil then FOleInPlaceActiveObject := IOIPAO;
end;
end;
if FOleInPlaceActiveObject <> nil then
if ((Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP)) and
(Msg.wParam in StdKeys) then
//nothing - do not pass on Backspace, Left, Right, Up, Down arrows
else FOleInPlaceActiveObject.TranslateAccelerator(Msg);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Webbrowser1.Navigate('www.SwissDelphiCenter.ch');
end;
initialization
OleInitialize(nil);
finalization
OleUninitialize
end.
Tuesday, 22 May 2018
Android Notification
unit UnitNotification;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
System.Notification, FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
NotificationCenter1: TNotificationCenter;
Button1: TButton;
procedure DoNotification(aName, aTitle, aBody: string);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.DoNotification(aName, aTitle, aBody: string);
var
appNotification: TNotification;
begin
appNotification := NotificationCenter1.CreateNotification;
try
appNotification.Name := aName;
appNotification.Title := aTitle;
appNotification.AlertBody := aBody;
NotificationCenter1.PresentNotification(appNotification);
finally
appNotification.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DoNotification('Test Name', 'Test Title', 'This is an example');
end;
end.
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
System.Notification, FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
NotificationCenter1: TNotificationCenter;
Button1: TButton;
procedure DoNotification(aName, aTitle, aBody: string);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.DoNotification(aName, aTitle, aBody: string);
var
appNotification: TNotification;
begin
appNotification := NotificationCenter1.CreateNotification;
try
appNotification.Name := aName;
appNotification.Title := aTitle;
appNotification.AlertBody := aBody;
NotificationCenter1.PresentNotification(appNotification);
finally
appNotification.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DoNotification('Test Name', 'Test Title', 'This is an example');
end;
end.
Monday, 21 May 2018
System tray icon in Windows for FireMonkey app, examples
http://www.devsuperpage.com/search/Articles.aspx?G=2&ArtID=135482 Is not an option. procedure Tmain_form.FormCreate(Sender: TObject); var nid : TNotifyIconData; A: array [0..78] of Char; begin StrPCopy(A, ParamStr(0)); with nid do begin cbSize := SizeOf; Wnd := FmxHandleToHWND(self.Handle); uID := 1; uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP; uCallbackMessage := 100; hIcon := ExtractIconW(HInstance, A, 0); StrPCopy(szTip, 'This is my icon'); end; Shell_NotifyIcon( NIM_ADD, @nid ); end; This is my idea, but needs refinement. |
[worked] FireMonkey隐藏任务栏图标
FMX(FireMonkey)可以轻松实现很多VCL无法或难以实现的特效,所以将FMX程序作为界面,打包入DLL由VCL程序调用,是一个不错的方案。为了程序的完整性,你不想看见FMX程序在任务栏上显示图标。可是普通的Windows函数似乎没有作用,比如你取得FMX窗体的句柄后,使用ShowWindow函数隐藏任务栏图标,结果是毫无作用。其实原因很简单,只是你使用的句柄不正确而已。
正确的源代码我贴出来,具体我就不解释了,相信有基础的人都能看懂。
unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Platform.Win,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
//隐藏主程序在任务栏的图标
ShowWindow(ApplicationHWND, SW_HIDE);
//隐藏主程序在alt+tab中的图标
SetWindowLong(ApplicationHWND, GWL_EXSTYLE, WS_EX_TOOLWINDOW Or GetWindowLong(ApplicationHWND, GWL_EXSTYLE));
end;
end.
正确的源代码我贴出来,具体我就不解释了,相信有基础的人都能看懂。
unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Platform.Win,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
//隐藏主程序在任务栏的图标
ShowWindow(ApplicationHWND, SW_HIDE);
//隐藏主程序在alt+tab中的图标
SetWindowLong(ApplicationHWND, GWL_EXSTYLE, WS_EX_TOOLWINDOW Or GetWindowLong(ApplicationHWND, GWL_EXSTYLE));
end;
end.
Wednesday, 2 May 2018
Delphi - How to get list of USB removable hard drives and memory sticks?
https://stackoverflow.com/questions/3718192/delphi-how-to-get-list-of-usb-removable-hard-drives-and-memory-sticks?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
{$MINENUMSIZE 4}
const
IOCTL_STORAGE_QUERY_PROPERTY = $002D1400;
type
STORAGE_QUERY_TYPE = (PropertyStandardQuery = 0, PropertyExistsQuery, PropertyMaskQuery, PropertyQueryMaxDefined);
TStorageQueryType = STORAGE_QUERY_TYPE;
STORAGE_PROPERTY_ID = (StorageDeviceProperty = 0, StorageAdapterProperty);
TStoragePropertyID = STORAGE_PROPERTY_ID;
STORAGE_PROPERTY_QUERY = packed record
PropertyId: STORAGE_PROPERTY_ID;
QueryType: STORAGE_QUERY_TYPE;
AdditionalParameters: array [0..9] of AnsiChar;
end;
TStoragePropertyQuery = STORAGE_PROPERTY_QUERY;
STORAGE_BUS_TYPE = (BusTypeUnknown = 0, BusTypeScsi, BusTypeAtapi, BusTypeAta, BusType1394, BusTypeSsa, BusTypeFibre,
BusTypeUsb, BusTypeRAID, BusTypeiScsi, BusTypeSas, BusTypeSata, BusTypeMaxReserved = $7F);
TStorageBusType = STORAGE_BUS_TYPE;
STORAGE_DEVICE_DESCRIPTOR = packed record
Version: DWORD;
Size: DWORD;
DeviceType: Byte;
DeviceTypeModifier: Byte;
RemovableMedia: Boolean;
CommandQueueing: Boolean;
VendorIdOffset: DWORD;
ProductIdOffset: DWORD;
ProductRevisionOffset: DWORD;
SerialNumberOffset: DWORD;
BusType: STORAGE_BUS_TYPE;
RawPropertiesLength: DWORD;
RawDeviceProperties: array [0..0] of AnsiChar;
end;
TStorageDeviceDescriptor = STORAGE_DEVICE_DESCRIPTOR;
function GetBusType(Drive: AnsiChar): TStorageBusType;
var
H: THandle;
Query: TStoragePropertyQuery;
dwBytesReturned: DWORD;
Buffer: array [0..1023] of Byte;
sdd: TStorageDeviceDescriptor absolute Buffer;
OldMode: UINT;
begin
Result := BusTypeUnknown;
OldMode := SetErrorMode(SEM_FAILCRITICALERRORS);
try
H := CreateFile(PChar(Format('\\.\%s:', [AnsiLowerCase(Drive)])), 0, FILE_SHARE_READ or FILE_SHARE_WRITE, nil,
OPEN_EXISTING, 0, 0);
if H <> INVALID_HANDLE_VALUE then
begin
try
dwBytesReturned := 0;
FillChar(Query, SizeOf(Query), 0);
FillChar(Buffer, SizeOf(Buffer), 0);
sdd.Size := SizeOf(Buffer);
Query.PropertyId := StorageDeviceProperty;
Query.QueryType := PropertyStandardQuery;
if DeviceIoControl(H, IOCTL_STORAGE_QUERY_PROPERTY, @Query, SizeOf(Query), @Buffer, SizeOf(Buffer), dwBytesReturned, nil) then
Result := sdd.BusType;
finally
CloseHandle(H);
end;
end;
finally
SetErrorMode(OldMode);
end;
end;
procedure GetUsbDrives(List: TStrings);
var
DriveBits: set of 0..25;
I: Integer;
Drive: AnsiChar;
begin
List.BeginUpdate;
try
Cardinal(DriveBits) := GetLogicalDrives;
for I := 0 to 25 do
if I in DriveBits then
begin
Drive := Chr(Ord('a') + I);
if GetBusType(Drive) = BusTypeUsb then
List.Add(Drive);
end;
finally
List.EndUpdate;
end;
end;
Spesifikasi Harga Teripang
http://sinarlautannusantara.blogspot.my/p/spesifikasi-harga-teripang.html
I. Jenis Teripang buang kulit
1. Ukuran 06 - 10 ekor/ kg Rp. 600,000,.
2. Ukuran 10 - 15 ekor/ kg Rp. 450,000,.
3. Ukuran 15 – 20 ekor / kg Rp. 355,500,.
4. Ukuran 20 – 25 ekor / kg Rp. 307,500,.
5. Ukuran 25 – 30 ekor / kg Rp. 260,000,.
6. Ukuran 30 – 35 ekor / kg Rp. 245,000,.
7. Ukuran 40 – 45 ekor / kg Rp. 220,000,.
8. Ukuran 45 – 60 ekor / kg Rp. 210,000,.
9. Ukuran 80 – 100 ekor / kg Rp. 180,000,.
10. Ukuran 100 – 125 ekor / kg Rp. 160,000,.
11. Ukuran 125 – 150 ekor / kg Rp. 150,000,.
12. Ukuran 150 – 200 ekor / kg Rp. 140,000,.
13. Ukuran 200 – 250 ekor / kg Rp. 130,000,.
14. Ukuran 250 – 300 ekor / kg Rp. 95,500,.
15. Ukuran 300 – 400 ekor / kg Rp. 85,000,.
16. Ukuran 400 – 600 ekor / kg Rp. 75,000,.
17. Ukuran 600 – 1000 ekor / kg Rp. 50,500,.
II. Jenis Teripang Susu
1. Ukuran 3 – 4 ekor / kg Rp. 325,000,.
2. Ukuran 4 – 5 ekor / kg Rp. 215,000,.
3. Ukuran 7 – 8 ekor / kg Rp. 210,000,.
III. Jenis Teripang TKK
1. TKK Super 10 cm UP Rp. 277,000,.
2. TKK Besar 9 cm UP Rp. 245,000,.
3. TKK Sedang 6 cm UP Rp. 180,000,.
4. TKK Kecil 4 cm UP Rp. 62,500,.
5. TKK Halus 3 cm UP Rp. 23,750,.
IV. Jenis Terpang Kapuk
1. Ukuran 15 – 17 ekor / kg Rp. 325,000,.
2. Ukuran 20 – 30 ekor / kg Rp. 145,000,.
3. Ukuran 40 – 60 ekor / kg Rp. 72,500,.
4. Ukuran 80 – 100 ekor / kg Rp. 62,500,.
V. Jenis Teripang Nanas
1. Ukuran 6 – 10 ekor / kg Rp. 350,000,.
2. Ukuran 10 – 15 ekor / kg Rp. 275,000,.
VI. Jenis Teripang Sepatu
1. Ukuran 10 – 15 ekor / kg Rp. 225,000,.
2. Ukuran 15 – 25 ekor / kg Rp. 125,000,.
3. Ukuran 40 – 60 ekor / kg Rp. 75,500,.
4. Ukuran 80 – 100 ekor / kg Rp. 54,500,.
VII. Jenis Teripang Jepung
1. Ukuran 80 – 100 ekor / kg Rp. 305,500,.
2. Ukuran 100 – 180 ekor / kg Rp. 244,500,.
VIII. Jenis Teripang Kapuk Bola
1. Ukuran 10 – 17 ekor / kg Rp. 450,000,.
2. Ukuran 17 – 25 ekor / kg Rp. 230,000,.
IX. Jenis Teripang Gama
1. Gama Bintik Besar u/k 10 – 20 ekor / kg Rp. 125,000,.
2. Gama Bintik Sedang u/k 25 –30 ekor/ kg Rp. 75,250,.
3. Gama Bintik Kecil u/k 40 – 45 ekor / kg Rp. 65,500,.
I. Jenis Teripang buang kulit
1. Ukuran 06 - 10 ekor/ kg Rp. 600,000,.
2. Ukuran 10 - 15 ekor/ kg Rp. 450,000,.
3. Ukuran 15 – 20 ekor / kg Rp. 355,500,.
4. Ukuran 20 – 25 ekor / kg Rp. 307,500,.
5. Ukuran 25 – 30 ekor / kg Rp. 260,000,.
6. Ukuran 30 – 35 ekor / kg Rp. 245,000,.
7. Ukuran 40 – 45 ekor / kg Rp. 220,000,.
8. Ukuran 45 – 60 ekor / kg Rp. 210,000,.
9. Ukuran 80 – 100 ekor / kg Rp. 180,000,.
10. Ukuran 100 – 125 ekor / kg Rp. 160,000,.
11. Ukuran 125 – 150 ekor / kg Rp. 150,000,.
12. Ukuran 150 – 200 ekor / kg Rp. 140,000,.
13. Ukuran 200 – 250 ekor / kg Rp. 130,000,.
14. Ukuran 250 – 300 ekor / kg Rp. 95,500,.
15. Ukuran 300 – 400 ekor / kg Rp. 85,000,.
16. Ukuran 400 – 600 ekor / kg Rp. 75,000,.
17. Ukuran 600 – 1000 ekor / kg Rp. 50,500,.
II. Jenis Teripang Susu
1. Ukuran 3 – 4 ekor / kg Rp. 325,000,.
2. Ukuran 4 – 5 ekor / kg Rp. 215,000,.
3. Ukuran 7 – 8 ekor / kg Rp. 210,000,.
III. Jenis Teripang TKK
1. TKK Super 10 cm UP Rp. 277,000,.
2. TKK Besar 9 cm UP Rp. 245,000,.
3. TKK Sedang 6 cm UP Rp. 180,000,.
4. TKK Kecil 4 cm UP Rp. 62,500,.
5. TKK Halus 3 cm UP Rp. 23,750,.
IV. Jenis Terpang Kapuk
1. Ukuran 15 – 17 ekor / kg Rp. 325,000,.
2. Ukuran 20 – 30 ekor / kg Rp. 145,000,.
3. Ukuran 40 – 60 ekor / kg Rp. 72,500,.
4. Ukuran 80 – 100 ekor / kg Rp. 62,500,.
V. Jenis Teripang Nanas
1. Ukuran 6 – 10 ekor / kg Rp. 350,000,.
2. Ukuran 10 – 15 ekor / kg Rp. 275,000,.
VI. Jenis Teripang Sepatu
1. Ukuran 10 – 15 ekor / kg Rp. 225,000,.
2. Ukuran 15 – 25 ekor / kg Rp. 125,000,.
3. Ukuran 40 – 60 ekor / kg Rp. 75,500,.
4. Ukuran 80 – 100 ekor / kg Rp. 54,500,.
VII. Jenis Teripang Jepung
1. Ukuran 80 – 100 ekor / kg Rp. 305,500,.
2. Ukuran 100 – 180 ekor / kg Rp. 244,500,.
VIII. Jenis Teripang Kapuk Bola
1. Ukuran 10 – 17 ekor / kg Rp. 450,000,.
2. Ukuran 17 – 25 ekor / kg Rp. 230,000,.
IX. Jenis Teripang Gama
1. Gama Bintik Besar u/k 10 – 20 ekor / kg Rp. 125,000,.
2. Gama Bintik Sedang u/k 25 –30 ekor/ kg Rp. 75,250,.
3. Gama Bintik Kecil u/k 40 – 45 ekor / kg Rp. 65,500,.
Tuesday, 24 April 2018
socket 传输文件编程 传送大文件的算法
http://www.greensoftcode.net/techntxt/201141310049498110245
我采用的开发语言是delphi 当然采用其它开发语言大同小异。
在写代码之前先说下网络传送协议:常用的网络文件传输协议为:TCP 和UDP,两者的区别是TCP是面向连接的 UDP是非面向连接的。TCP所谓的面向连接的及三次握手协议,报文头加入验证字段等很复杂
UDP相对TCP报头帧相对简单无验证帧。
一.udp 传送文件的特点:
1.速度快
2.传送质量差可能丢包。
3.1m小文件最佳
二、tcp 传送文件的特点:
1.传送文件速度相对UDP较慢。
2.传送质量较高丢包情况较少
3.大文件传送佳。
三、udp传送代码:
采用delphi IdUDPClient、IDUDPSERVER的的控件
//发送端
function udpsenchangefile(filename:string ;ip:string;port:integer; bar:TProgressBar;mainfrm:TForm;iconarr:array of TIcon;label1:TLabel;label2:TLabel):boolean; //发送文件
var
receivedString:string;
stream:TFileStream;
posi,len:integer;
p:array[0..1023] of byte;
sendresult:boolean; //发送结果
sendedsize :integer; //已发送字节数
udpclient:TIdUDPClient ;
begin
sendedsize:=0;
sendresult:=false;
udpclient:= TIdUDPClient.Create(Application);
udpclient.Host:=ip;
udpclient.Port:=port;
if not udpclient.Active then udpclient.Active:=true;
posi:=0;
stream:=nil;
try
stream:=tfileStream.Create(filename,fmOpenRead);
if stream.Size>0 then
udpclient.Send('token'+'|'+filename+'|'+IntToStr(stream.Size));
receivedString:=udpclient.ReceiveString();
if uppercase(receivedString)=upperCase('agree-accept')then
begin
udpclient.Active:=false;
udpclient.Free ;
while posi<stream.Size do
begin
udpclient:= TIdUDPClient.Create(Application); //每发送一个文件建立一个对象 因为 我用一个控件时发送大于1M文件就程序就死掉啦!
udpclient.Host:=ip;
udpclient.Port:=port;
udpclient.ReceiveTimeout:=-2;
udpclient.BufferSize :=1024000;
udpclient.BroadcastEnabled:=false;
if not udpclient.Active then udpclient.Active:=true;
len:= sendbytesize; //只能发 sendbytesize
if stream.Size< len then //如果长度不到 sendbytesize
len:=stream.Size;
stream.Read(p,len);
udpclient.SendBuffer(p,len);
sendedsize:=sendedsize+1;
inc(posi,len);
label1.Caption:=inttostr(stream.Size);
bar.Position:=round(posi/stream.size*100);
//softtitle:=softtitle+inttostr(sendedsize)+'字节';
receivedString:=udpclient.ReceiveString();
//if ( sendedsize>0 )and (sendedsize mod 1000 =0) then Delay(5000);
label2.Caption:=inttostr( sendedsize);
if upperCase(ReceivedString)<>upperCase('receivedok') then break;
application.ProcessMessages;
changeico(mainfrm,softtitle, iconarr) ;
udpclient.Active:=false;
udpclient.Free ;
end;
udpclient.Send('tokenfilal');
if udpclient.ReceiveString()='receivefilal' then
sendresult:=true;
end
else
sendresult:=false;
finally
stream.Free;
end;
Result:=sendresult;
end;
接受端:
procedure Tmainfrm.udpserverUDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
str ,receiveval:string;
temp:TStringList;
begin
aData.Seek(0,0);
setLength(receiveval,aData.size);
aData.Read(receiveval[1],aData.Size);
temp:= SplitString(receiveval,'|');
case protocol.IndexOf(temp[0]) of
0: begin
receiveFileName:=temp[1];
receiveFileSize:=strtoint(temp[2]);
filename:=createreceivedir(receiveFileName,receivedir);
if not fileExists(filename) then
stream:=TFileStream.Create(FileName,sysutils.fmOpenReadWrite or fmCreate)
else
stream:=TFileStream.Create(FileName,fmopenReadWrite);
str:='agree-accept';
abinding.SendTo(aBinding.PeerIP ,aBindIng.PeerPort ,str[1],length(str));
end ;
1:
if stream<>nil then
begin
successfilesynchcount:=successfilesynchcount+1;
stream.Free;
stream:=nil;
str:='receivefilal';
aBinding.SendTo(aBinding.PeerIP,aBinding.PeerPort,str[1],length(str));
filename:='';
receiveFileName:='';
receiveFileSize:=0;
receivsize:=0;
softtitle:='目前成功接受'+inttostr(successfilesynchcount)+'个文件!';
end;
else
if stream<>nil then
begin
receivsize:=receivsize+1;
softtitle:='正在接受'+ filename ;
stream.Seek(0,2);
aData.Seek(0,0);
stream.CopyFrom(aData,aData.Size);
label1.Caption:=inttostr( receivsize) ;
Bar.Position:=round(stream.size/receiveFileSize*100);
str:='receivedok';
abinding.SendTo(aBinding.PeerIP,aBinding.PeerPort,str[1],length(str));
label2.Caption:=inttostr( receivsize) ;
application.ProcessMessages;
changeico(mainfrm,softtitle, notifyicon) ;
end;
end;
end;
通过这个例子udp 发送大文件时我发现确实存在不可靠事件,及文件可能没发送完!
要想准确发送成功!可能还要改进算法
tcp 发送例子
发送端:
function tcpsenchangefile(filename:string ;ip:string;port:integer; bar:TProgressBar;mainfrm:TForm;iconarr:array of TIcon):boolean; //发送文件
var
receivedString:string;
stream:TFileStream;
ReadCount : Integer;
Buf:array[0..1023] of byte;
sendresult:boolean; //发送结果
tcpclient:TIdTCPClient ;
begin
sendresult:=false;
tcpclient:=TIdTCPClient.Create(Application);
tcpclient.Host:=ip;
tcpclient.Port:=port;
if not tcpclient.Connected then tcpclient.Connect(5000);
stream:=nil;
try
stream:=tfileStream.Create(filename,fmOpenRead);
if stream.Size>0 then tcpclient.WriteLn('token'+'|'+filename+'|'+IntToStr(stream.Size));
receivedString:=tcpclient.ReadLn(#13#10, 1000);
if uppercase(receivedString)=upperCase('agree-accept')then
begin
while stream.Position < stream.Size do
begin
if stream.Size - stream.Position >= SizeOf(Buf) then
ReadCount := sizeOf(Buf)
else ReadCount := stream.Size - stream.Position;
stream.ReadBuffer(Buf, ReadCount);
tcpclient.WriteBuffer(Buf, ReadCount);
//receivedString:=tcpclient.ReadLn(#13#10, 1000);
//if upperCase(ReceivedString)<>upperCase('receivedok') then break;
changeico(mainfrm,softtitle, iconarr) ;
end;
tcpclient.WriteLn('tokenfilal');
receivedString:=tcpclient.ReadLn(#13#10, 1000);
if receivedString='receivefilal' then sendresult:=true;
tcpclient.Disconnect;
end;
except
sendresult:=false;
end;
tcpclient.Disconnect;
if stream<>nil then FreeAndNil(stream);
if tcpclient<>nil then FreeAndNil(tcpclient);
Result:=sendresult;
end;
接受端
procedure Tmainfrm.tcpserverExecute(AThread: TIdPeerThread);
var
str ,receiveval:string;
temp:TStringList;
Buff : array[0..1023] of Byte; // Buff 缓存区大小设置,byte型
ReadCount : Integer; //实际每次读取文件块的大小,整型
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
if State= dstNone then
receiveval := AThread.Connection.ReadLn(#13#10, 1000);
if receiveval='' then Exit;
temp:= SplitString(receiveval,'|');
if protocol.IndexOf(temp[0])=0 then
begin
receiveFileName:=temp[1];
receiveFileSize:=strtoint(temp[2]);
filename:=createreceivedir(receiveFileName,receivedir);
if not fileExists(filename) then
stream:=TFileStream.Create(FileName,sysutils.fmOpenReadWrite or fmCreate)
else
stream:=TFileStream.Create(FileName,fmopenReadWrite);
str:='agree-accept';
AThread.Connection.WriteLn(str);
State := dstReceiving;
end
else
begin
successfilesynchcount:=successfilesynchcount+1;
str:='receivefilal';
AThread.Connection.WriteLn(str);
filename:='';
receiveFileName:='';
receiveFileSize:=0;
receivsize:=0;
softtitle:='目前成功接受'+inttostr(successfilesynchcount)+'个文件!';
end;
end;
if stream<>nil then
begin
repeat
if receiveFileSize - Stream.Size > SizeOf(Buff) then
ReadCount := SizeOf(Buff)
else
ReadCount := receiveFileSize - Stream.Size;
AThread.Connection.ReadBuffer(Buff, ReadCount); //从连接中读取 ReadCount长度的文件块放到缓冲区Buff,中
stream.WriteBuffer(Buff, ReadCount); //将缓冲区中的内容写进文件流中,这是就是写到文件aFileName中啦
Bar.Position:=round(stream.size/receiveFileSize*100);
Application.ProcessMessages; //这句作用是让消息传递动态显示起来,如果没有这句上面的caption是不会显示跳动的
changeico(mainfrm,softtitle, notifyicon) ;
// str:='receivedok';
// AThread.Connection.WriteLn(str);
until Stream.Size >= receiveFileSize; //直到文件大小和原文件大小一致结束循环
State := dstNone;
stream.Free;
stream:=nil;
end;
end;
Tcp 发送大小文件测试过程中全部成功!这说明TCP发送文件可靠性比较强!算法要求低。
上面的算法有些变量没有写全 但核心代码没有问题 测试通过!
在写代码之前先说下网络传送协议:常用的网络文件传输协议为:TCP 和UDP,两者的区别是TCP是面向连接的 UDP是非面向连接的。TCP所谓的面向连接的及三次握手协议,报文头加入验证字段等很复杂
UDP相对TCP报头帧相对简单无验证帧。
一.udp 传送文件的特点:
1.速度快
2.传送质量差可能丢包。
3.1m小文件最佳
二、tcp 传送文件的特点:
1.传送文件速度相对UDP较慢。
2.传送质量较高丢包情况较少
3.大文件传送佳。
三、udp传送代码:
采用delphi IdUDPClient、IDUDPSERVER的的控件
//发送端
function udpsenchangefile(filename:string ;ip:string;port:integer; bar:TProgressBar;mainfrm:TForm;iconarr:array of TIcon;label1:TLabel;label2:TLabel):boolean; //发送文件
var
receivedString:string;
stream:TFileStream;
posi,len:integer;
p:array[0..1023] of byte;
sendresult:boolean; //发送结果
sendedsize :integer; //已发送字节数
udpclient:TIdUDPClient ;
begin
sendedsize:=0;
sendresult:=false;
udpclient:= TIdUDPClient.Create(Application);
udpclient.Host:=ip;
udpclient.Port:=port;
if not udpclient.Active then udpclient.Active:=true;
posi:=0;
stream:=nil;
try
stream:=tfileStream.Create(filename,fmOpenRead);
if stream.Size>0 then
udpclient.Send('token'+'|'+filename+'|'+IntToStr(stream.Size));
receivedString:=udpclient.ReceiveString();
if uppercase(receivedString)=upperCase('agree-accept')then
begin
udpclient.Active:=false;
udpclient.Free ;
while posi<stream.Size do
begin
udpclient:= TIdUDPClient.Create(Application); //每发送一个文件建立一个对象 因为 我用一个控件时发送大于1M文件就程序就死掉啦!
udpclient.Host:=ip;
udpclient.Port:=port;
udpclient.ReceiveTimeout:=-2;
udpclient.BufferSize :=1024000;
udpclient.BroadcastEnabled:=false;
if not udpclient.Active then udpclient.Active:=true;
len:= sendbytesize; //只能发 sendbytesize
if stream.Size< len then //如果长度不到 sendbytesize
len:=stream.Size;
stream.Read(p,len);
udpclient.SendBuffer(p,len);
sendedsize:=sendedsize+1;
inc(posi,len);
label1.Caption:=inttostr(stream.Size);
bar.Position:=round(posi/stream.size*100);
//softtitle:=softtitle+inttostr(sendedsize)+'字节';
receivedString:=udpclient.ReceiveString();
//if ( sendedsize>0 )and (sendedsize mod 1000 =0) then Delay(5000);
label2.Caption:=inttostr( sendedsize);
if upperCase(ReceivedString)<>upperCase('receivedok') then break;
application.ProcessMessages;
changeico(mainfrm,softtitle, iconarr) ;
udpclient.Active:=false;
udpclient.Free ;
end;
udpclient.Send('tokenfilal');
if udpclient.ReceiveString()='receivefilal' then
sendresult:=true;
end
else
sendresult:=false;
finally
stream.Free;
end;
Result:=sendresult;
end;
接受端:
procedure Tmainfrm.udpserverUDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
str ,receiveval:string;
temp:TStringList;
begin
aData.Seek(0,0);
setLength(receiveval,aData.size);
aData.Read(receiveval[1],aData.Size);
temp:= SplitString(receiveval,'|');
case protocol.IndexOf(temp[0]) of
0: begin
receiveFileName:=temp[1];
receiveFileSize:=strtoint(temp[2]);
filename:=createreceivedir(receiveFileName,receivedir);
if not fileExists(filename) then
stream:=TFileStream.Create(FileName,sysutils.fmOpenReadWrite or fmCreate)
else
stream:=TFileStream.Create(FileName,fmopenReadWrite);
str:='agree-accept';
abinding.SendTo(aBinding.PeerIP ,aBindIng.PeerPort ,str[1],length(str));
end ;
1:
if stream<>nil then
begin
successfilesynchcount:=successfilesynchcount+1;
stream.Free;
stream:=nil;
str:='receivefilal';
aBinding.SendTo(aBinding.PeerIP,aBinding.PeerPort,str[1],length(str));
filename:='';
receiveFileName:='';
receiveFileSize:=0;
receivsize:=0;
softtitle:='目前成功接受'+inttostr(successfilesynchcount)+'个文件!';
end;
else
if stream<>nil then
begin
receivsize:=receivsize+1;
softtitle:='正在接受'+ filename ;
stream.Seek(0,2);
aData.Seek(0,0);
stream.CopyFrom(aData,aData.Size);
label1.Caption:=inttostr( receivsize) ;
Bar.Position:=round(stream.size/receiveFileSize*100);
str:='receivedok';
abinding.SendTo(aBinding.PeerIP,aBinding.PeerPort,str[1],length(str));
label2.Caption:=inttostr( receivsize) ;
application.ProcessMessages;
changeico(mainfrm,softtitle, notifyicon) ;
end;
end;
end;
通过这个例子udp 发送大文件时我发现确实存在不可靠事件,及文件可能没发送完!
要想准确发送成功!可能还要改进算法
tcp 发送例子
发送端:
function tcpsenchangefile(filename:string ;ip:string;port:integer; bar:TProgressBar;mainfrm:TForm;iconarr:array of TIcon):boolean; //发送文件
var
receivedString:string;
stream:TFileStream;
ReadCount : Integer;
Buf:array[0..1023] of byte;
sendresult:boolean; //发送结果
tcpclient:TIdTCPClient ;
begin
sendresult:=false;
tcpclient:=TIdTCPClient.Create(Application);
tcpclient.Host:=ip;
tcpclient.Port:=port;
if not tcpclient.Connected then tcpclient.Connect(5000);
stream:=nil;
try
stream:=tfileStream.Create(filename,fmOpenRead);
if stream.Size>0 then tcpclient.WriteLn('token'+'|'+filename+'|'+IntToStr(stream.Size));
receivedString:=tcpclient.ReadLn(#13#10, 1000);
if uppercase(receivedString)=upperCase('agree-accept')then
begin
while stream.Position < stream.Size do
begin
if stream.Size - stream.Position >= SizeOf(Buf) then
ReadCount := sizeOf(Buf)
else ReadCount := stream.Size - stream.Position;
stream.ReadBuffer(Buf, ReadCount);
tcpclient.WriteBuffer(Buf, ReadCount);
//receivedString:=tcpclient.ReadLn(#13#10, 1000);
//if upperCase(ReceivedString)<>upperCase('receivedok') then break;
changeico(mainfrm,softtitle, iconarr) ;
end;
tcpclient.WriteLn('tokenfilal');
receivedString:=tcpclient.ReadLn(#13#10, 1000);
if receivedString='receivefilal' then sendresult:=true;
tcpclient.Disconnect;
end;
except
sendresult:=false;
end;
tcpclient.Disconnect;
if stream<>nil then FreeAndNil(stream);
if tcpclient<>nil then FreeAndNil(tcpclient);
Result:=sendresult;
end;
接受端
procedure Tmainfrm.tcpserverExecute(AThread: TIdPeerThread);
var
str ,receiveval:string;
temp:TStringList;
Buff : array[0..1023] of Byte; // Buff 缓存区大小设置,byte型
ReadCount : Integer; //实际每次读取文件块的大小,整型
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
if State= dstNone then
receiveval := AThread.Connection.ReadLn(#13#10, 1000);
if receiveval='' then Exit;
temp:= SplitString(receiveval,'|');
if protocol.IndexOf(temp[0])=0 then
begin
receiveFileName:=temp[1];
receiveFileSize:=strtoint(temp[2]);
filename:=createreceivedir(receiveFileName,receivedir);
if not fileExists(filename) then
stream:=TFileStream.Create(FileName,sysutils.fmOpenReadWrite or fmCreate)
else
stream:=TFileStream.Create(FileName,fmopenReadWrite);
str:='agree-accept';
AThread.Connection.WriteLn(str);
State := dstReceiving;
end
else
begin
successfilesynchcount:=successfilesynchcount+1;
str:='receivefilal';
AThread.Connection.WriteLn(str);
filename:='';
receiveFileName:='';
receiveFileSize:=0;
receivsize:=0;
softtitle:='目前成功接受'+inttostr(successfilesynchcount)+'个文件!';
end;
end;
if stream<>nil then
begin
repeat
if receiveFileSize - Stream.Size > SizeOf(Buff) then
ReadCount := SizeOf(Buff)
else
ReadCount := receiveFileSize - Stream.Size;
AThread.Connection.ReadBuffer(Buff, ReadCount); //从连接中读取 ReadCount长度的文件块放到缓冲区Buff,中
stream.WriteBuffer(Buff, ReadCount); //将缓冲区中的内容写进文件流中,这是就是写到文件aFileName中啦
Bar.Position:=round(stream.size/receiveFileSize*100);
Application.ProcessMessages; //这句作用是让消息传递动态显示起来,如果没有这句上面的caption是不会显示跳动的
changeico(mainfrm,softtitle, notifyicon) ;
// str:='receivedok';
// AThread.Connection.WriteLn(str);
until Stream.Size >= receiveFileSize; //直到文件大小和原文件大小一致结束循环
State := dstNone;
stream.Free;
stream:=nil;
end;
end;
Tcp 发送大小文件测试过程中全部成功!这说明TCP发送文件可靠性比较强!算法要求低。
上面的算法有些变量没有写全 但核心代码没有问题 测试通过!
Sunday, 22 April 2018
Wednesday, 18 April 2018
Delphi获取目录下所有文件名,子目录名-南山古桃(转+修改)-关键词:Delphi,获取文件名,子目录名
procedure searchfile(path:string);//注意,path后面要有'\';
var
SearchRec:TSearchRec;
found:integer;
begin
found:=FindFirst(path+'*.*',faAnyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>'.') and (SearchRec.Name<>'..')
and (SearchRec.Attr<>faDirectory) then
begin
Form1.ListBox1.Items.Add(SearchRec.Name);
end;
found:=FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
http://taochaotc.blog.163.com/blog/static/1733711620085109343731/
var
SearchRec:TSearchRec;
found:integer;
begin
found:=FindFirst(path+'*.*',faAnyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>'.') and (SearchRec.Name<>'..')
and (SearchRec.Attr<>faDirectory) then
begin
Form1.ListBox1.Items.Add(SearchRec.Name);
end;
found:=FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
http://taochaotc.blog.163.com/blog/static/1733711620085109343731/
Tuesday, 17 April 2018
文件名函数可以对文件的名称、所在子目录、驱动器和扩展名等进行操作
函数说明
ExpandFileName()
//返回文件的全路径(含驱动器、路径)
ExtractFileExt()
//从文件名中抽取扩展名
ExtractFileName()
//从文件名中抽取不含路径的文件名
ExtractFilePath()
//从文件名中抽取路径名
ExtractFileDir()
//从文件名中抽取目录名
ExtractFileDrive()
//从文件名中抽取驱动器名
ChangeFileExt()
//改变文件的扩展名
ExpandUNCFileName()
//返回含有网络驱动器的文件全路径
ExtractRelativePath()
//从文件名中抽取相对路径信息
ExtractShortPathName()
//把文件名转化为DOS的8·3格式
MatchesMask()
//检查文件是否与指定的文件名格式匹配
ExtractFilePath(FileName:
String
)
//该函数返回路径名,其结尾字符总是“\”
ExtractFileDir(FileName:
String
)
//该函数同样返回路径名,但不包括结尾的字符“\”,除非返回的路径是根目录。
Thursday, 12 April 2018
except on E
try
Except on E : Exception do
begin
ShowMessage('Timeout Error, dont worry');
end;
end;
Except on E : Exception do
begin
ShowMessage('Timeout Error, dont worry');
end;
end;
Wednesday, 11 April 2018
Indy10 TrivialFTP client
https://www.experts-exchange.com/questions/22980786/Indy10-TrivialFTP-client.html
there seems to be some bug in indy
go in idtrivialftp.pas, line 272 in latest indy 10.
looe for the line
CurrentDataBlk := WordToStr(GStack.HostToNet
work(Word( TFTP_DATA) )) + WordToStr(GStack.HostToNet work(Block Ctr));
and make it look like
CurrentDataBlk := WordToStr(GStack.HostToNet work(Word( TFTP_DATA) )) + WordToStr(GStack.HostToNet work(word( BlockCtr)) );
notice the word explicit type conversion of BlockCtr
this fixes the range check error. (I thought you got a compiler warnign :D )
then, on line 274 uncomment the line
SourceStream.ReadBuffer(Cu rrentDataB lk[hdrsize +1], DataLen);
and that should do it. the example at least, clicking on button2, will upload that text from the memory stream)
there seems to be some bug in indy
go in idtrivialftp.pas, line 272 in latest indy 10.
looe for the line
CurrentDataBlk := WordToStr(GStack.HostToNet
and make it look like
CurrentDataBlk := WordToStr(GStack.HostToNet
notice the word explicit type conversion of BlockCtr
this fixes the range check error. (I thought you got a compiler warnign :D )
then, on line 274 uncomment the line
SourceStream.ReadBuffer(Cu
and that should do it. the example at least, clicking on button2, will upload that text from the memory stream)
[vcl worked]Getting local IP address in Delphi
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Winsock;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Function GetIPAddress():String;
type
pu_long = ^u_long;
var
varTWSAData : TWSAData;
varPHostEnt : PHostEnt;
varTInAddr : TInAddr;
// sypoh namebuf : Array[0..255] of char;
namebuf: array [0..63] of Ansichar;
begin
If WSAStartup($101,varTWSAData) <> 0 Then
Result := 'No. IP Address'
Else Begin
gethostname(namebuf,sizeof(namebuf));
varPHostEnt := gethostbyname(namebuf);
varTInAddr.S_addr := u_long(pu_long(varPHostEnt^.h_addr_list^)^);
Result := 'IP Address: '+inet_ntoa(varTInAddr);
End;
WSACleanup;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption := GetIPAddress;
end;
end.
IdTrivialFTP1
http://borland.newsgroups.archived.at/public.delphi.internet.winsock/200805/08050813988.html
Thursday, 5 April 2018
Android实例-路径信息及文件和文件夹的操作
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ScrollBox,
FMX.Memo, FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
System.IoUtils;
{$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID}
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Clear;
Memo1.Lines.Add('GetTempFileName:' + TPath.GetTempFileName);
Memo1.Lines.Add('GetTempPath:' + TPath.GetTempPath);
Memo1.Lines.Add('GetHomePath:' + TPath.GetHomePath);
Memo1.Lines.Add('GetDocumentsPath:' + TPath.GetDocumentsPath);
Memo1.Lines.Add('GetSharedDocumentsPath:' + TPath.GetSharedDocumentsPath);
Memo1.Lines.Add('GetLibraryPath:' + TPath.GetLibraryPath);
Memo1.Lines.Add('GetCachePath:' + TPath.GetCachePath);
Memo1.Lines.Add('GetPathRoot:' + TPath.GetPathRoot(TPath.GetCachePath));
Memo1.Lines.Add('GetPublicPath:' + TPath.GetPublicPath);
Memo1.Lines.Add('GetPicturesPath:' + TPath.GetPicturesPath);
Memo1.Lines.Add('GetSharedPicturesPath:' + TPath.GetSharedPicturesPath);
Memo1.Lines.Add('GetCameraPath:' + TPath.GetCameraPath);
Memo1.Lines.Add('GetSharedCameraPath:' + TPath.GetSharedCameraPath);
Memo1.Lines.Add('GetMusicPath:' + TPath.GetMusicPath);
Memo1.Lines.Add('GetSharedMusicPath:' + TPath.GetSharedMusicPath);
Memo1.Lines.Add('GetMoviesPath:' + TPath.GetMoviesPath);
Memo1.Lines.Add('GetAlarmsPath:' + TPath.GetAlarmsPath);
Memo1.Lines.Add('GetSharedAlarmsPath:' + TPath.GetSharedAlarmsPath);
Memo1.Lines.Add('GetDownloadsPath:' + TPath.GetDownloadsPath);
Memo1.Lines.Add('GetSharedDownloadsPath:' + TPath.GetSharedDownloadsPath);
Memo1.Lines.Add('GetRingtonesPath:' + TPath.GetRingtonesPath);
Memo1.Lines.Add('GetSharedRingtonesPath:' + TPath.GetSharedRingtonesPath);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if TFile.Exists(TPath.GetTempFileName) then
begin
Memo1.Lines.Clear;
Memo1.Lines.Add('存在');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if not TDirectory.Exists(TPath.GetTempPath + 'NewDirectory') then
TDirectory.CreateDirectory(TPath.GetTempPath + 'NewDirectory');
end;
procedure TForm1.Button4Click(Sender: TObject);
var
sFile1: string;
sFile2: string;
begin
sFile1 := TPath.GetTempPath + '123.jpg';
sFile2 := TPath.GetTempPath + '456.jpg';
if not TFile.Exists(sFile1) then
begin
TFile.Copy(sFile1, sFile2);
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
var
Files: TStringDynArray;
I: Integer;
begin
if TDirectory.Exists(TPath.GetTempPath + '/temp/') then
begin
Files := TDirectory.GetFiles(TPath.GetTempPath + '/temp/');
for I := 0 to high(Files) do
begin
TFile.Delete(Files[I]);
end;
end;
end;
end.
Subscribe to:
Posts (Atom)
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required.
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required. h...
-
Grows your business with zomok online ordering platform. Zero commission. Suitable for restaurants, kopitiam, food, groceries, pet supplie...
-
Complete TFTP Server example, using Indy components There are not many good TFTP server examples out there, so I wrote this example of...