锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
鍦ㄦ父鎴忎腑蹇呴』灞忚斀windows瀵圭矘婊為敭鐑敭鐨勫弽搴旓紝鍚﹀垯娓告垙浣撻獙灝嗕細闈炲父宸傚湪緗戜笂鏌ユ壘涓孌墊椂闂村悗鍙戠幇錛屽叧浜庡浣曢氳繃紼嬪簭灞忚斀綺樻粸閿儹閿殑涓枃璧勬枡闈炲父灝戯紝澶у鏁扮殑絳旀閮芥槸鎵撳紑“鎺у埗闈㈡澘”錛岀劧鍚庢壘鍒?#8220;杈呭姪鍔熻兘閫夐」”鏉$洰浜戜簯錛岃繖鏄劇ず涓嶆槸紼嬪簭鍛樻墍闇瑕佺殑瑙e喅鎵嬫硶銆?br> 緇忚繃澶氭柟鏌ユ壘錛岄棶棰樻渶緇堝緱浠ヨВ鍐熾備笅闈㈠垪琛ㄤ唬鐮侊紝浠ラ(鏈潵鑰咃紝紼嬪簭VC6.0+XP緋葷粺涓嬭繍琛岄氳繃銆?br>
bool ActivateStickyHotkey(bool isActivate, bool* pIsPreviouslyActivate= NULL)
{
// fetch current sticky keys state
STICKYKEYS skf;
const DWORD datasize = sizeof(STICKYKEYS);
skf.cbSize = datasize;
if (!SystemParametersInfo(SPI_GETSTICKYKEYS, datasize, (LPVOID)&skf, 0))
{
return false;
}
const bool isPreviouslyActivate = (skf.dwFlags & SKF_HOTKEYACTIVE) != 0;
// store old sticky keys state
if (NULL!= pIsPreviouslyActivate)
{
*pIsPreviouslyActivate = isPreviouslyActivate;
}
// return true if no need to change state
if (isActivate==isPreviouslyActivate)
{
return true;
}
// change sticky keys state
skf.dwFlags = isActivate? (skf.dwFlags | SKF_HOTKEYACTIVE) : (skf.dwFlags & (~SKF_HOTKEYACTIVE));
const bool isSuccess = TRUE==SystemParametersInfo(SPI_SETSTICKYKEYS, datasize, (LPVOID)&skf, 0);
return isSuccess;
}
鍙傝冭祫鏂欙細
1, http://msdn.microsoft.com/en-us/library/aa925903.aspx
2, http://stackoverflow.com/questions/734618/disabling-accessibility-shortcuts-in-net-application
]]>


def getTaxRatio(taxSalary):
ratiolist =(
(500, 0.05, 0),
(2000, 0.10, 25),
(5000, 0.15, 125),
(20000, 0.20, 375),
(40000, 0.25, 1375),
(60000, 0.30, 3375),
(80000, 0.35, 6375),
(100000, 0.40, 10375),
(9999999,0.45, 15375)
)
if taxSalary>= 0:
for ratio in ratiolist:
if taxSalary<= ratio[0]:
return (ratio[1], ratio[2])
return (0, 0)
def calcYearAwardTax(yearAward):
monthAward = yearAward / 12
taxRatio, taxAdjust = getTaxRatio(monthAward)
tax = yearAward * taxRatio - taxAdjust
resultAward = yearAward - tax
retcode = (yearAward, resultAward, tax, taxRatio, taxAdjust)
#print('yearAward= %d, resultAward= %f, tax= %f, taxRatio= %f, taxAdjust= %d'%retcode)
return retcode

################################################################################
import sys
import os
argNum = len(sys.argv)
if argNum == 1:
scriptName = os.path.basename(__file__)
print('usage1: %s awardUpperBound'%scriptName)
print('usage2: %s awardLowerBound awardUpperBound'%scriptName)
sys.exit()

print('-----------------------------------------------------------------------')
awardLowerBound, awardUpperBound = 0, 0
if argNum == 2:
awardUpperBound = int(sys.argv[1])
elif argNum == 3:
awardLowerBound, awardUpperBound = int(sys.argv[1]), int(sys.argv[2])
if awardLowerBound> awardUpperBound:
swap(awardLowerBound, awardUpperBound)
perfectAward, perfectGain = 0, 0
for award in range(awardLowerBound, awardUpperBound + 1):
retcode = calcYearAwardTax(award)
if len(retcode) > 2:
if retcode[1]> perfectGain:
perfectAward = retcode[0]
perfectGain = retcode[1]
if award== awardUpperBound:
print('upperBoundAward= %d,\tgain= %f,\ttax= %f'%(retcode[0], retcode[1], retcode[0] - retcode[1])) 
print("perfectAward= %d,\tgain= %f,\ttax= %f"%(perfectAward, perfectGain, perfectAward - perfectGain))


淇濆瓨鎴愭枃浠?awardTax.py 鐒跺悗鍦ㄥ懡浠よ璋冪敤鍗沖彲銆?br>姣斿浣犲勾緇堝鍙戜簡25000錛屽垯錛?br>
ok, 閭d箞浣犱簭浜嗭紝浣犳瘮鎷?4000鐨勫悓蹇楀浜ょ◣3625-2375= 1250鍏冿紝鏈緇堟敹鐩婅繕姣斾粬灝?1625-21375= 250鍏冦?br>榪欎釜鏁板兼鏈浣崇殑騫寸粓濂栨暟棰濅負24000錛屽洜姝よ繕鏄悜鑰佹澘鐢寵灝戠粰浣犲彂鐐瑰勾緇堝鍚с?
]]>
import hashlib
class FileHash(object):
def __hash_file(self, filepath):
if os.path.exists(filepath):
m= hashlib.md5()
with open(filepath, 'rb') as fin:
while True:
data= fin.read(8096)
if not data:
break
m.update(data)
return m.hexdigest()
def compare_file(self, srcfile, destfile):
src_md5= self.__hash_file(srcfile)
dest_md5= self.__hash_file(destfile)
isOk= (src_md5==dest_md5)
return isOk
if __name__ == '__main__':
file_hash= FileHash()
srcdir =r'E:\game'
destdir =r'C:\game'
for root, dirs, files in os.walk(srcdir):
for filename in files:
src_file_path = os.path.join(root, filename)
dest_file_path = os.path.join(destdir, src_file_path[len(srcdir)+1:])
cur_dest_dir= os.path.split(dest_file_path)[0]
if not os.path.exists(cur_dest_dir):
shutil.copytree(root, cur_dest_dir)
print('created dir: %s'%cur_dest_dir)
elif not os.path.exists(dest_file_path) or not file_hash.compare_file(src_file_path, dest_file_path):
shutil.copyfile(src_file_path, dest_file_path)
print('created file: %s'%dest_file_path)
]]>
import urllib.request
import urllib.parse
import ctypes
SetSystemTime = ctypes.windll.kernel32.SetSystemTime
GetSystemTime = ctypes.windll.kernel32.GetSystemTime
class SYSTEMTIME(ctypes.Structure):
c_ushort= ctypes.c_ushort
_fields_ = (
('wYear', c_ushort),
('wMonth', c_ushort),
('wDayOfWeek', c_ushort),
('wDay', c_ushort),
('wHour', c_ushort),
('wMinute', c_ushort),
('wSecond', c_ushort),
('wMilliseconds', c_ushort),
)
def __str__(self):
return '%4d%02d%02d%02d%02d%02d.%03d' % (self.wYear,self.wMonth,self.wDay,self.wHour,self.wMinute,self.wSecond,self.wMilliseconds)
def updateSystemTime():
url= 'http://www.baidu.com'
try:
response= urllib.request.urlopen(url)
header= response.info()
date=header['Date']
gmt=time.strptime(date[5:25], "%d %b %Y %H:%M:%S")
st=SYSTEMTIME(gmt.tm_year,gmt.tm_mon,gmt.tm_wday,gmt.tm_mday,gmt.tm_hour,gmt.tm_min,gmt.tm_sec,0)
SetSystemTime(ctypes.byref(st))
print('緗戠粶鏍℃椂鎴愬姛錛?/span>')
except Exception as ex:
print(ex)
print('緗戠粶鏍℃椂澶辮觸')
return False
return True
def printCurTime():
now= time.localtime(time.time())
print('褰撳墠緋葷粺鏃墮棿:', time.strftime("%Y-%m-%d %H:%M:%S", now))
if __name__=='__main__':
printCurTime()
if updateSystemTime():
printCurTime()
C:\>updatetime
褰撳墠緋葷粺鏃墮棿: 2009-12-16 16:51:11
緗戠粶鏍℃椂鎴愬姛錛?br>褰撳墠緋葷粺鏃墮棿: 2008-12-16 16:51:12
C:\>
銆涔嬪墠錛屾垜鏁呮剰鎶婃椂闂磋皟鏁村埌浜?009騫淬?br>
銆銆
]]>