1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
 
import mylog
from DBCommon import error
import GameWorld
import time
 
def EncodingToUnicode(srcEncoding, input):
    try:
        result = unicode(input, srcEncoding)    #translate to utf-8
    except:
        msg = error.formatMsg('error', error.ERROR_NO_5, 'encode error!srcEncoding = %s input = %s'%(srcEncoding, repr(input)))
        mylog.error(msg)
        return False, "error"
    return True, result
 
def UnicodeToEncoding(dstEncoding, input):
    try:
        result = input.encode(dstEncoding)
    except:
        msg = error.formatMsg('error', error.ERROR_NO_6, 'encode error!dstEncoding = %s input = %s'%(dstEncoding, repr(input)))        
        mylog.error(msg)
        return False, "Error"
    return True, result
  
#²éÕÒStructure¶ÔÏóµÄ×Ö¶Î,´óСдÃô¸Ð
def hasField(structObj, name):
    for field in structObj._fields_:
        fieldName = field[0]
        if fieldName == name:
            return True
    return False
 
def LoadLibraryEx(DllName):
    "DLL Load ,return the handle of the dll or None"
    from ctypes import windll
    try:
        return windll.LoadLibrary(DllName)
    except WindowsError:
        return None
    return None 
 
#µ¯¿òÀàÐÍ
MB_OK = 0
MB_OKCANCEL = 1
MB_ABORTRETRYIGNORE = 2
MB_YESNOCANCEL = 3
MB_YESNO = 4
MB_RETRYCANCEL = 5
MB_ICONHAND = 16
MB_ICONQUESTION = 32
MB_ICONEXCLAMATION = 48
MB_ICONASTERISK = 64
MB_ICONWARNING = MB_ICONEXCLAMATION
MB_ICONERROR = MB_ICONHAND
MB_ICONINFORMATION = MB_ICONASTERISK
MB_ICONSTOP = MB_ICONHAND
MB_DEFBUTTON1 = 0
MB_DEFBUTTON2 = 256
MB_DEFBUTTON3 = 512
MB_DEFBUTTON4 = 768
MB_APPLMODAL = 0
MB_SYSTEMMODAL = 4096
MB_TASKMODAL = 8192
MB_HELP = 16384
MB_NOFOCUS = 32768
MB_SETFOREGROUND = 65536
MB_DEFAULT_DESKTOP_ONLY = 131072
MB_TOPMOST = 262144
MB_RIGHT = 524288
MB_RTLREADING = 1048576
MB_SERVICE_NOTIFICATION = 2097152
MB_TYPEMASK = 15
MB_USERICON = 128
MB_ICONMASK = 240
MB_DEFMASK = 3840
MB_MODEMASK = 12288
MB_MISCMASK = 49152
# def MessageBox(title,msg,stype):
# #    import win32api,win32gui
# #    import win32con,winerror,win32event,pywintypes
# #    ct = win32api.GetConsoleTitle()
# #    hd = win32gui.FindWindow(0,ct)
# #    win32api.MessageBox(hd,msg,title,win32con.MB_OK)
#     hd = LoadLibraryEx("user32.dll")
#     if hd is not None:
#         return hd.MessageBoxA(0,msg,title,stype)
        
#½«¸¡µãÊýת»¯³É×Ö·û´®¸ñʽ        
g_dllTDateTimeFunc = None
def TDateTimeToString(dTime):
    return GameWorld.ChangeTimeNumToStr(dTime)
 
 
#·µ»ØÖµÎªDelphiµÄTDateTime£¬¼´doubleÀàÐ͵ÄNow()º¯Êý
def TDateTime_Now():
    return time.time()