廣告

2026 年 4 月
 12345
6789101112
13141516171819
20212223242526
27282930  

彙整

Delphi 下讓使用者選擇目錄方式:

Delphi 下讓使用者選擇目錄方式:

OpenDialog 元件是讓使用者選檔案,那選目錄要使用什麼方式呢?

USE QDialogs

procedure TForm1.cxButton1Click(Sender: TObject);
var
  Dir: WideString;
begin
  if SelectDirectory(‘請選擇目錄’, ”, Dir) then
  begin
    ShowMessage(Dir);
  end;
end;

SelectDirectory(‘請選擇目錄’, ”, Dir)

第一個參數為提示文字,第二個參數可設定預設目錄,第三個參數為使用者選取目錄後的目錄路徑

可對SelectDirectory按F1查詢使用方式,還有VCL的用法可用,代的參數又不一樣,有興趣的可研究一下。

有不會念的中文字?微”軟”新注音手寫板幫助您

1. 開起記事本
2.保持遊標在記事本上
3.切換成新注音輸入法
4.選取 工具選單 => 輸入法整合器 
1

在上面寫上文字,再把滑鼠移到到左邊對應的文字上停止,就可看到注音唸法了,當然點下去就會把選取的字輸出到記事本上,可當手寫板用。
2

Mailscanner取回隔離區的信-Releasing mail from the quarantine

Releasing mail from the quarantine – queue files

For the purposes of this, I’m assuming you have set up a single (safe!) postfix instance, with messages going to the HOLD queue, before being processed by MailScanner and sent to the INCOMING queue. You also need to be saving whole messages as queue files.

In MailScanner.conf ensure that you have

# When you quarantine an entire message, do you want to store it as
# raw mail queue files (so you can easily send them onto users) or
# as human-readable files (header then body in 1 file)?
Quarantine Whole Messages As Queue Files = yes 

Quarantined emails are by default kept in /var/spool/MailScanner/quarantine and sorted into subdirectories by date. With any luck it will be dead easy to find, as MailScanner will have sent a message including text along the lines of either:

A: If it’s a quarantined virus, or other dangerous content.

“Note to Help Desk: Look on the <Your text> in /var/spool/MailScanner/quarantine/20050309 (message
6BC5E368497.3C3A6).” 

MailScanner keeps such quarantined emails in their own directories, thus the directory containing the quarantined message will be (in this example): /var/spool/MailScanner/quarantine/20050309/6BC5E368497.3C3A6. In this directory, you should see the original queue file, named as a 10 digit hex number matching the name of the directory. There should also be copies of any attachments that may have been picked up by the virus scanning engine or file filtering.

B: If it’s a quarantined spam

"Your system administrators will need the following information:
Server name: <Your Server>
Message id: 46EE0E18151.CE630
Date code: 20080509"

MailScanner keeps all spam on a given day in the same directory, thus the directory containing the quarantined message will be (in this example): /var/spool/MailScanner/quarantine/20080509/spam.

If you want to check the original message use:

# postcat <filename>

Releasing an email from quarantine is a simple matter of replacing the queue file back into the Postfix queue, so that it gets sent. The permissions on the file are wrong, however and must be changed.

# chmod 700 <filename>

The file must now be moved into /var/spool/postfix/incoming. There may be 16 directories in there (Collectively referred to as ‘hashed queue files’) each corresponding to a hexadecimal digit, depending which version of Postfix you are running. First check if you have hashed queue files by:

# ls /var/spool/postfix/incoming

If no directories are listed then follow the instructions below but do not add the trailing letter/ number.

The file must be placed in the directory which corresponds to the first digit of the filename. So in the example above, it must go into /var/spool/postfix/incoming/6. We must also be sure to preserve the ownership and permissions of the file when moving it, so we use “cp -p”. If the message is a spam, we must also remove the trailing 6 characters.

Thus for the example above:

# cp –p 6BC5E368497 /var/spool/postfix/incoming/6

or for the example quarantined spam

# cp –p 46EE0E18151.CE630 /var/spool/postfix/incoming/4/46EE0E18151

The email will disappear from the queue and be delivered.

Thanks to Joshua Hirsh for the details and Stef Morrell for writing the document

Releasing mail from the quarantine – with a bash script

Maybe it’s too circuitous for you to do all the steps in the section above to release a mail. For this I wrote a tiny script to release very easily. To use this script you should set the MailScanner environment identically to the article above.

To use this script copy it to a file and make it executable.

The Syntax: release.sh <Message-ID> (e.g. release.sh 5B604228086.932F0)

#!/bin/sh

if [ -z "$1" ]; then
        echo "Syntax: release.sh <Message-ID> i.e. 5B604228086.932F0 (case sensitive)" 
        exit
fi

#change in the quarantine folder
folder=`find /var/spool/MailScanner/quarantine/ -name $1`
cd $folder

#set the mailfile executable
mailname=`echo $1 | cut -d . -f 1`
chmod u+x $mailname

#lets get the first character
char=`echo $1 | cut -b 1-1`

#copy the mail 
cp -a $mailname /var/spool/postfix/incoming/$char/

echo Mail $mailname released

Releasing mail from the quarantine – message files

If you don’t quarantine the complete queue file, but instead have the rfc822 message file, releasing messages are actually a bit simpler (for postfix) than the above, since you can use the postfix sendmail convenience program.

In MailScanner.conf you have

Quarantine Whole Messages As Queue Files = no 

and in the quarantine directory you have a file called message (this is the complete human-readible message, but without the envelope info). Just do

cd /path/to/quarantine/dir
sendmail -t -i < message

to send the message to the recipient(s) as found in the message file, or

cd /path/to/quarantine/dir
sendmail -i alternate_recipient@example.net < message

to send the message to an alternate recipient (of course you can combine them). The -i option is to avoid terminating the message prematurely on a spurious single “.” on a line in the message file.

If you use MailWatch, this can also release the message iff you don’t quarantine the whole message file as the queue file, although this uses a different method to release messages from the GUI.

Releasing mail from the quarantine – queue files postfix (again)

In a larger environment with many hosts and thousands of quarantined emails per day, we’ve found it impractical to reply to each email released or deleted from a queue, and simply process it without fanfare. The code below is modified from the release.sh above to accomodate moving the released mail back into postfix using the original mail ID. In addition, our postfix install required us to rename the queue file to its shortname, that is, the 10 or 11 character filename before postfix would accept the email into the queue.

The Syntax: release.sh <Message-ID> (e.g. release.sh 5B604228086.932F0)

#!/bin/sh

if [ -z "$1" ]; then
        echo "Syntax: release.sh <Message-ID> i.e. 5B604228086.932F0 (case sensitive)" 
        exit
fi

#change in the quarantine folder
folder=`find /var/spool/MailScanner/quarantine/ -name $1 | sed -e "s/$1//g"`
cd $folder

#set the mailfile executable
mailname=`echo $1 | cut -d . -f1`
chmod u+x $1

#lets get the first character
char=`echo $1 | cut -b 1-1`

#copy the mail 
cp -a $1 /var/spool/postfix/incoming/$char/$mailname

The following is for recent postfixes (2.3, 2.4) which seem to have a flat incoming directory:

#!/bin/sh

# this is the final destination for the mail to be released:
# postfix's incoming queue
POSTFIX_DEST=/var/spool/postfix/incoming

# check for valid parameters
if [ -z "$1" ]; then
        echo "Syntax: release.sh <Message-ID>"
        echo "Example: release.sh 678362AC.9CFE7"
        exit
fi

# find the specific mail in the quarantine folders
folder=`find /var/spool/MailScanner/quarantine/ -name $1`

mailname=`echo $1 | cut -d . -f1`

# copy the mail 
if [ -e $POSTFIX_DEST/$mailname ] ; then
        echo "ERROR: $mailname already in $POSTFIX_DEST! EXITING"
        echo "This should not happen"
        exit 255
fi

cp -avi "$folder/$mailname" "$POSTFIX_DEST/$mailname"

# make it 0700 so that the mail is deemed ready
chmod 0700 $POSTFIX_DEST/$mailname

Releasing mail from the quarantine – the one liner

sudo install -m 0700 -o postfix <source message> /var/spool/postfix/incoming

Releasing mail from the quarantine – alias with intelligence

integrate() {
  # integration: antonym of quarantine
  # Pass the message ID as obtained from user's email as $1
  DEST=$(postconf queue_directory | cut -d= -f2)/incoming
  SOURCE=$(find /var/spool/MailScanner/quarantine -name "$1")
  install --verbose --mode=0700 --owner=postfix $SOURCE $DEST
}

Updated bash script

Line 9 on initial bash script returned filename with full path and not folder, as expected. Instructions at the top also used the cp -p option, and not -a. Instead of cd’ing to quarantine folder, this will do the copy and preserve permissions.

#!/bin/sh

if [ -z "$1" ]; then
        echo "Syntax: release.sh <Message-ID> i.e. 5B604228086.932F0 (case sensitive)" 
        exit
fi

#find the quarantined file and set permissions
quarantined_file=`find /var/spool/MailScanner/quarantine/ -name $1`
chmod u+x $quarantined_file

#truncate the filename
mailname=`echo $1 | cut -d . -f 1`

#lets get the first character
char=`echo $1 | cut -b 1-1`

#copy the mail, destination is the truncated filename
cp -p $quarantined_file /var/spool/postfix/incoming/$char/$mailname

echo Mail $mailname released

截取印表機驅動程式

截取印表機驅動程式:

如果有台PC有某台印表機的DRIVER,但是你想把這台印表機的DRIVER轉到SERVER上,可是網路上卻抓不到此台印表機的Driver,就可用這程式抓取,小巧好用!

http://www.novell.com/communities/node/350/printer%20driver%20generator

台灣的未來?!

經國先生說:

一個國家的年輕人如何?就可以看出這個國家的未來  我已經看到台灣的未來了!

2010.12.18 花蓮洄瀾200k NeverStop極限挑戰

17號早上7點2x分的火車,上車前一照

2010-12-16 22.32.28 2010-12-17 07.19.23 2010-12-17 07.19.38

2010-12-17 07.22.58  2010-12-17 07.23.15 2010-12-17 07.24.32

========================================

火車開動囉,邁向花蓮,各路英雄齊上火車,好不熱鬧,照例接著小弟準備要睡了….

 2010-12-17 09.09.09 2010-12-17 09.09.13

========================================

花東海岸美景

 2010-12-17 11.34.30 2010-12-17 11.36.41

========================================

來,好兄弟親一下!

2010-12-17 11.50.37

========================================

到花蓮了,約4個多小時…

 2010-12-17 12.07.592010-12-17 12.07.53

========================================

走後門快速通過…外面剛下過雨又濕又冷,卻擋不住大家的熱情~~

2010-12-17 12.12.10 2010-12-17 12.12.16 2010-12-17 12.12.28 2010-12-17 12.12.43

========================================

花蓮車站前隨拍…

 2010-12-17 12.20.13 2010-12-17 12.25.33

========================================

車站前幫路人修烙鍊後一起去吃中餐…路邊攤能吃到690也不簡單…應該是貴在透抽跟大腸吧…不過還滿好吃的。

2010-12-17 13.15.19 2010-12-17 13.19.37

========================================

吃飽即前往鯉魚潭報到…結果在這邊留下黃金萬兩……XD

2010-12-17 15.20.22 2010-12-17 15.20.31 2010-12-17 15.20.46

2010-12-17 15.32.36 2010-12-17 15.33.12 2010-12-17 15.38.04

========================================

報到完畢就到鯉魚潭晃晃

2010-12-17 15.43.00 2010-12-17 15.44.02 2010-12-17 15.46.43

2010-12-17 15.46.51 2010-12-17 15.47.30 2010-12-17 15.58.02

========================================

回住宿路上經過理想度假村的路標照了一張,這邊要進房間得搭船,真是特別!途中又經過花蓮農會開的冰店,就進去吃冰了,雖然此時只有不到10度的天氣…..

 2010-12-17 16.08.28 2010-12-17 16.37.20 2010-12-17 16.39.58

兩個怪叔叔吃冰的模樣…….

2010-12-17 16.41.042010-12-17 16.42.17 2010-12-17 16.42.37

========================================

晚餐來到有名的公正包店,原來是小籠包,還以為是一般的大包子,不過10顆50真的很便宜,也不錯吃!

2010-12-17 20.00.59 2010-12-17 20.13.15

========================================

馬上轉往自強夜市,不同於台南的花蓮棺材板,我真的是在拍棺材板…….XD

2010-12-17 20.51.05 2010-12-17 20.58.35 2010-12-17 20.58.39

========================================

臨走前帶點有名的烤肉回去吃吧… 難怪騎腳踏車的要減肥是件很困難的事…….XD

2010-12-17 21.22.51

========================================

準備好感應貼紙….1808 兩個發…..

2010-12-17 23.08.31

========================================

隔天3點半起床,到達會場已經4點半了,先來幾張照片吧……看,曼妙的身材,不拍對不起自己….XD

2010-12-18 04.38.12 2010-12-18 04.39.49 2010-12-18 04.43.15 2010-12-18 04.46.41

========================================

離五點出發的時間不遠了

2010-12-18 04.53.19 2010-12-18 04.53.29

========================================

夜騎真是件舒服的事,沒車又涼快!來!阿姑再親一下 XD 親完看看花蓮的日出…..光線

2010-12-18 06.39.47 2010-12-18 06.40.09 2010-12-18 06.39.23

========================================

縱谷中穿梭………爬坡怎比下坡多?!

2010-12-18 06.40.54 2010-12-18 06.41.01 2010-12-18 06.41.07

 2010-12-18 06.56.232010-12-18 06.42.01

========================================

繼上個月彰化110K休息太久吊車尾入榜的經驗,不敢多停留,所以拍的照不多,這是第一個補給站,騎了80多公里才到,幾乎快完成彰化賽事了,花了4個小時多一些……想必已經有變態到達第二站了….

麵包有三種口味,個人喜歡蒜味 XD

2010-12-18 09.07.14 2010-12-18 09.07.42 2010-12-18 09.08.10  

========================================

到第二補給站前 騎了一百多公里終於看到第一家7-11 中餐時間到了 能挑的不多 涼麵隨便吃吃….旁邊就是垃圾桶……

2010-12-18 11.48.06 2010-12-18 11.53.39 2010-12-18 11.57.50

========================================

第二補給站離第一補給站約4X公里,來到這前我又破胎了,難道就離不開破胎魔咒嗎?環化賽也是破胎,是我太重嗎? 蝦米 ! 貢丸已經被吃完,剩下蘿蔔湯….是還不錯喝啦….但是有貢丸會更好點,下次自己帶好了,不然都被公路車的兄台吃光光 >_<

2010-12-18 12.45.38 2010-12-18 12.45.55

========================================

出發前看到有路人的腳踏車壞了,她說已經騎了120公里,不想放棄,但是方圓五百哩,沒半個腳踏車店…..只好安慰她要她多吃兩根香蕉,然後還有專車可以座,剩下的由我來幫她完成吧….XD

2010-12-18 12.51.04 2010-12-18 12.51.20 2010-12-18 12.51.28

========================================

果然不能幸災樂禍…..到達北回歸線,靠北~~~邊走…..又破胎了,這次補了騎沒多久,氣就漏光了,只好請朋友先走,看到義工,索性回頭問問指揮交通的義工哪有腳踏車店,結果是沒半家,正想著等會可以跟剛的妹一起坐專車…..沒想到他們有賣內胎,26吋的法嘴,我的美嘴框框可以裝,經過幾次破胎的洗禮,拿出工具很快地拆輪檢查並換上內胎,在此感謝這兩位義工的幫忙幫我呼叫的救援車以及來救援的大會人員,剛好缺打氣筒,裝完上路後一路戰戰兢兢地完成了賽事。不過爆胎王子於是就這樣誕生了………..

2010-12-18 13.08.59 2010-12-18 13.09.21 

========================================

一路苦苦追趕,後面實在沒啥力,太餓了我,本來平均22公里,變成14公里,還以為我又破胎了……..離終點約15公里前忽然看到小吃店,二話不說迴轉叫了碗大碗的滷肉飯,因為特別餓,所以特別好吃,老闆說,我來之前有個人叫了牛肉麵+小魯肉飯…..連吃都比輸人…………

2010-12-18 16.15.34

========================================

吃完後活力源源不絕,一路3X公里追趕,終於趕上朋友,到終點前朋友腳抽筋,看來抽筋王子的封號非他莫屬……最後也完成了賽事,花了12小時又28分………比預期的最後10分鐘結束前到達終點,還有1個小時的時間,是快了許多,不過看到很多女性朋友比我早回來……….有種三溫暖的心情……五味雜陳……不過平安完成賽事就是喜事!期待下次的賽事見!

========================================

回家的火車上,倒一片,抽筋王子當然也是其中一個,至於爆胎王子….越來越像老人,松山站起來後竟然睡不著了……最後平安回到新竹,半夜2點半的新竹車站,巴洛克式建築,真美!

2010-12-18 22.17.58 2010-12-19 01.03.33 2010-12-19 01.13.37 2010-12-19 02.26.45

好用的1919乘法,可快速算11~19的相乘方法

印度的1919乘法(補充說明)

想到之前台灣不是叫小學生連99乘法表都不要背了嗎…?

當台灣媽媽因為小朋友會背99乘法高興的同時…

印度小孩已經在被1919乘法了!

難怪近幾年印度進步得那麼快!


印度的九九乘法表是從1背到19(→19×19乘法?)

不過您知道印度人是怎麼記11到19的數字嗎?

我是看了下面這本書之後才恍然大悟的…

「印度式計算訓練」

2007年6月10日第一版第6刷發行株式會社晉遊社發售…

介紹了加減乘除的各種快速計算方法…

不過在這裡我只介紹印度的九九乘法…

因為實在太神奇了!!

下面的數字跟說明都是引用該書P.44的例子…

請試著用心算算出下面的答案:

13×12=?
(被乘數)×(乘數)=?

印度人是這樣算的…

****************************************************************************

第一步:
先把被乘數(13)跟乘數的個位數(2)加起來
13+2=15

第二步:
然後把第一步的答案乘以10(→也就是說後面加個0)

15×10=150

第三步:
再把被乘數的個位數(3)乘以乘數的個位數(2)
2×3=6

(13+2)×10+6=156

****************************************************************************

就這樣,用心算就可以很快地算出11×11到19×19了喔!

這真是太神奇了!

我們試著演算一下…

14×13:
(1)14+3=17
(2)17×10=170
(3)4×3=12
(4)170+12=182

16×17:
(1)16+7=23
(2)23×10=230
(3)6×7=42
(4)230+42=272

真的是耶,好簡單喔!

怎不早點讓我知道呢?!

DELPHI 7 使用ADO元件寫入資料庫強制四捨五入小數到第四位問題

DELPHI 7 使用ADO元件寫入資料庫強制四捨五入小數到第四位問題

parameters.parambyname(‘tmpprice’).datatype:=ftFloat;   <==寫入資料前先將欄位設定成 Float 型態即可解決此問題。

參考:http://jzinfo.javaeye.com/blog/432853

  1. var  
  2.     adoquery1:Tadoquery;  
  3. begin  
  4.     adoquery1:=Tadoquery.create(nil);  
  5.     try  
  6.        if not DM.adonconnection1.connected then  
  7.            DM.adoconnection1.connected:=true;  
  8.        adoquery1.connection:=DM.adoconnection1;  
  9.        adoquery1.enableBCD:=False;       //禁用bcd类型  
  10.        with adoquery1 do  
  11.        begin  
  12.            close;  
  13.            sql.clear;  
  14.            sql.add(‘insert into materialInfo values(:tmppno,:tmpvendor,:tmpdesc,:tmpprice)’);  
  15.            parameters.parambyname(‘tmppno’).value:=trim(edit1.text);  
  16.            parameters.parambyname(‘tmpvendor’).value:=trim(edit2.text);  
  17.            parameters.parambyname(‘tmpdesc’).value:=trim(edit3.text);  
  18.            parameters.parambyname(‘tmpprice’).datatype:=ftFloat;       //设置下数据类型  
  19.            parameters.parambyname(‘tmpprice’).value:=trim(edit4.text);  
  20.            execsql;  
  21.        end;  
  22.     finally  
  23.         adoquery1.free;  
  24.     end;  
  25. end; 

使用GPO關閉outlook express 會出現壓縮的提示訊息

參考:http://aesoptw.blogspot.com/2010/09/outlook-express.html

文章中有提到
此帳號的 UUID
uuid每台電腦不同
以前都要逐一幫user建這個檔

所附的指令碼會自動抓到這個值

請把以下指令碼複製存成bat或cmd檔

———-
CLS
@ECHO OFF
FOR /F "skip=10 tokens=3 delims=\" %%a IN (‘reg query HKCU\Identities’) DO (
REG ADD "HKCU\Identities\%%a\Software\Microsoft\Outlook Express\5.0"
/v "Compact Check Count" /t REG_DWORD /d 0 /f
)
———

然後加入GPO中使用電腦設定加入開機SCRIPT即可。

ESX下VM機器安裝 USB裝置方式

參考文章:http://www.benjr.tw/?q=node/634

ESX下有很多VM機器,但是實體連USB裝置的在同一時間內只有一台可以連,那麼要怎麼指定USB裝置給那台使用呢? VM Workstation 下只要把視窗作用,然後插入usb裝置後,在該VM下就可以直接連接USB裝置,但是在ESX下要指定USB裝置給那台VM機器使用,則要做一些設定,設定方式如下:

1. 先將欲使用的USB裝置插入該台ESX SERVER實體硬體上。

2. 進 vSphere Cliet

3. 開啟要連USB裝置的硬體設定畫面,確認有USB controller裝置。

clip_image002

4. 新增USB裝置,若不確定,可先拔除實體USB然後再做到這步驟看看與接上USB裝置後的差別來判定那個USB裝置是您要的。

clip_image004

clip_image005

5. 新增完VM機器上的USB裝置,應該可以看到對應的VM機器上抓到USB裝置使用。

clip_image006